I was a little startled by this too, I thought I had been using sleep(0) in C to sleep until receiving an ALRM for years, and that this idiom would fall through to perl. Apparently you need to set up a handler, even a null handler would work, to catch the signal instead of the default handler, which appears to print out "Alarm clock" and crap out. Experiments and results below: [david@plaza david]$ perl -le 'sleep 0; print "slept"' & slept [1] 1618 [1] Done perl -le 'sleep 0; print "slept"' [david@plaza david]$ perl -le 'sleep 9990; print "slept"' & [1] 1622 [david@plaza david]$ kill -ALRM 1622 [david@plaza david]$ [1]+ Alarm clock perl -le 'sleep 9990; print "slept"' [david@plaza david]$ perl -le '$SIG{ALRM} = sub{ print "alarmed" } ; sleep 9990; print "slept"' & [1] 1623 [david@plaza david]$ kill -ALRM 1623 [david@plaza david]$ alarmed slept [david@plaza david]$ On Mon, 2003-10-13 at 03:41, Doug Sibley wrote: > http://www.perl.com/doc/manual/html/pod/perlfunc/sleep.html > > says "May be interrupted if the process receives a signal such as > SIGALRM" (as do the O'Reilly series of perl books) which led me to > believe that I could sleep until I sent a SIGALRM at which point the > process would continue. > > You may wish to update either the behavior or comments of the sleep > function. > > - Doug > > On Sat, 2003-10-11 at 09:20, Michael G Schwern wrote: > > Doesn't seem like one to me. The program was killed by a SIGALRM and > > exited abnormally. Your exit(0) is never reached. > > > > perlipc states that Perl "does the default thing" to handle a signal if > > you don't tell it otherwise. The OS X (ie. BSD) signals(3) man page states > > that the default action for SIGALRM is to terminate the process. -- david nicol "In your own mind, you are the hoopiest frood. That is all that matters." -- Gargoyle CabbitThread Previous | Thread Next