in reply to Re^2: SIGCHLD and sleep()
in thread SIGCHLD and sleep()

You should be able to the reaping in a SIGCHLD handler, which upon exit, returns you to the sleep loop. Or include the reaping within the timing loop, eg
while (1) { while (remaining) { sleep(remaining); while (($pid = wait) != -1) { ... do reaping stuff } } ... check for new jobs and spawn them ... }

Dave.

Replies are listed 'Best First'.
Re^4: SIGCHLD and sleep()
by Anonymous Monk on Aug 09, 2005 at 21:45 UTC
    Thanks again for your help. This is actually what I ended up doing (reaping within the timing loop), and was just returning to post about. It seems to work well, without cluttering the process table with defunct processes. It would've only been ~1 min before they got reaped, but it's still ugly to see those zombies in the process table.

    overbyte