Hello all,

I'm working on an application which basically does the following:

1. Create pipes for stdin/stdout/stderr
2. Fork

Then for the child:
1. Close unneeded side of the pipes, close 0, 1, 2, dup the pipes to stdin, stdout and stderr
2. Wait for a single-char message on stdin
3. Continue the program, sending data to stdout/stderr

Then for the parent:
1. Wait until we can read or write from one of the pipes (poll)
2. Do whatever we can do (all input is already available before this runs, so we close the input pipe on our end). If we can send output, first send a single character. (to stop waiting for a single char message in the child)

Now, most of the times it works fine. Sometimes, the output doesn't seem to work (that is, the child can't send on the stdout and stderr pipes). If I sleep for a little while in the child, however, it always works fine.

What could the problem be?


Thanks in advance.