Use the reaper code from perlipc/"Signals" to call wait() when a SIGCHLD is received, or else use the double-fork technique described in perlfunc/fork.