Setting up both channels of communication, or even all three, can be tricky, because it implies that you have to both send and receive data, needing to coordinate the two processes in such a way as to avoid deadlocks. From what I understand, if you don’t read from the stdout
or stderr
pipes (when present), they can fill up and block the child process. You sometimes see this when trying to wait()
for the child (it never exits). It’s best when the processes only send and receive data only in predictable ways.
As for my original problem, when the parent process was sometimes getting stuck in read()
after the child exited, I don’t know.