-1

In my code, the parent process does not need to wait these children processes. And I need to know which child process finishes first to do rest of the code.

3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by dkalita
0

If the parent process doesn't have to wait, why does it care who finishes first.

If at least one child process needs to finish, then you have to wait.

0

In my code, the parent process does not need to wait these children processes. And I need to know which child process finishes first to do rest of the code.

In the parent process u already have the child process id's.
U can repeatedly use the 'ps' command to ckeck which processes are running. Whenever u get one process missing break the loop and continue. And now u have the process id which just finished.

I dont know how to check the status of the processes in other way (there must be some).
u can do

system("ps>processes");
//this will store the output to the file 'processes'
//parse from the file whatever u need.

Hope thats of some help

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.