create and listen to a process
(Using C on ubuntu)
In my program I need to fork a process and execute a .bin in the child process. Then I want to create a pipe that "connects" the stdout of the child to the stdout of the parent. I know basically how to do this using write() and read() in the pipes.
The problem is that the parent should wait until the child sends a specific message (a string), or until a timeout occurs. In the first case both processes should run in "parallel" ( I don't know if its the correct term..), in the second case the child must abort and the parent go on. And I don't have a clue how to accomplish any of this things. Any suggestions ?
I made a very basic skeleton, comments?
int fd; /* pipe */
if( pipe(fd) !=0 )
perror("Failed to create pipe");
perror("Failed to fork");
else if(pid == 0) /* child */
perror("Child unabled to start sixad");