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...