C IPC waiting for child
Posted
by Gary
on Stack Overflow
See other posts from Stack Overflow
or by Gary
Published on 2010-04-29T23:11:00Z
Indexed on
2010/04/29
23:17 UTC
Read the original article
Hit count: 248
So I have a program which creates a child process and executes a command (for example, ls). The parent will then use pipes to send to and get from the child. This works fine when I'm inputting commands myself from the command line.
However, when the input comes from a file, it seems like the child doesn't have enough time to run and I get NULL when reading from the pipe - even though there will be information coming from it.
Short of using sleep(), is there a better way to make sure the child has run before trying to read from it?
Thanks a lot!
© Stack Overflow or respective owner