|Perl Monk, Perl Meditation|
Sleeping and reapingby Starky (Chaplain)
|on Jan 14, 2003 at 21:49 UTC||Need Help??|
Starky has asked for the
wisdom of the Perl Monks concerning the following question:
I would like to have a parent process spawn a child to perform some task every 5 seconds. I would also like to perform some cleanup every time a child exits.
Unfortunately it appears that sleep exits prematurely when a CHLD signal handler is triggered; for example,
From the documentation for sleep, May be interrupted if the process receives a signal such as "SIGALRM".
I can put the sleep in backticks, which seems to work albeit kludgily, but I am annoyed that putting it in backticks will result in a CHLD signal whenever the subprocess exits which means I have to worry about which child it was that exited when the child signal is caught.
My question to the monks is: How would those wiser in the ways of slumber do this?