(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?
Code:
int status;
int fd[2]; /* pipe */
if( pipe(fd) !=0 )
{
perror("Failed to create pipe");
exit(EXIT_FAILURE);
}
pid_t pid=fork();
if( pid<0)
{
perror("Failed to fork");
exit(EXIT_FAILURE);
}
else if(pid == 0) /* child */
{
if(execl("/usr/bin/sixad","sixad","-s",NULL)==-1);
perror("Child unabled to start sixad");
exit(EXIT_FAILURE);
}
sorry for the cross posting in the linux forum. I ask the moderators to eliminate the other post please.