in reply to Re^3: open with pipe
in thread open with pipe

Calling waitpid twice for the same process doesn't seem right to me.