// JP opened flex table

Click to See Complete Forum and Search --> : wait vs waitpid


vr84
December 27th, 2007, 10:27 PM
I was reading about an echo server that forks a child to handle each client. To handle zombies the author said it was correct to use waitpid in a loop within the SIGCHLD signal handler rather than using wait inside the handler because wait blocks. My question is why would wait block, wouldn't it execute right away because it's inside the SIGCHLD handler, implying that a child terminated?

upredsun
December 28th, 2007, 12:26 AM
I think this is because that SIGCHLD signal is not safe.I mean,if you use wait func and the operating system happen to lost the SIGCHLD sigal,under this condition,your process will be blocked and i think this is not what you want!

vr84
December 29th, 2007, 04:06 PM
Thanks for the help, it seems that must be the case.

//JP added flex table