June 6th, 2009, 02:32 AM
Fork(), Waitpid(), and Pipe() problems.
I am having some trouble with the behavior of subsequent calls of waitpid() on fork()'ed processes with stdio redirected via pipe().
In trying to emulate "echo 12345 | grep 1" the correct output is generated, but it would appear that the grep process (via execvp) never dies, so the call to waitpid() on its pid stalls forever.
June 7th, 2009, 11:16 AM
Re: Fork(), Waitpid(), and Pipe() problems.
You need a third fork to run the echo() and grep() suimutaneously. With your code, you will hang on the waitpid() in the echo().
Tags for this Thread
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!