in reply to 100 years sleep on HPUX

It is possible that a wait can return -1 not when there are no children, but when things are being autoreaped. Also note that as noted in perlipc, you cannot rely on signal handlers being re-entrant. Setting a signal handler inside of a signal handler will not work on many platforms.

My sincere advice is to avoid playing with signal handlers for this. Just pull out Parallel::ForkManager to keep a fixed number of children alive. Alternately never sleep. Just use wait to block until a child exits, and then proceed.