Parent detect when forked processes exit

I'm trying to write a program that will fork a number of children processes that will run concurrently and exit after some randomized amount of time. My problem is that I need the parent to spit out a message each time a child exits as follows:

"Daughter PID EXITED after (t) seconds."

with actual values for PID and (t). How would I make the parent detect when an exit has occurred and then display the message?
Last edited on
You may want to take a look at waitpid with the WNOHANG option:
Awesome, thanks!
You may also think about SIGCHLD handling if your parent process shouldn't poll for terminating childs.
Topic archived. No new replies allowed.