Your SIGCHLD handler leaves much to be desired.
- You are interfering with the normal return of exit status,
so a program checking for that for a particular child might not get what they need.
- There's no guarantee (that I'm aware of) that promises one CHLD per dead child. Because of the way signals can be suspended or delivered, the CHLD signal really means "at some time in the recent past, one or more children went belly up". So you have failed to loop to grab multiple kids, and failed to ignore the possibility that the kid has already been reaped between the time the CHLD signal is initiated and your program runs to your handler.
So, this is a bad general example, and a bad specific example. Sorry.
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.