On Mon, Oct 13, 2003 at 09:41:08AM +0100, 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. Hmm. It should probably show an example of the usual idiom. --- pod/perlfunc.pod 2003/10/13 12:11:23 1.1 +++ pod/perlfunc.pod 2003/10/13 12:12:07 @@ -4576,10 +4576,18 @@ =item sleep Causes the script to sleep for EXPR seconds, or forever if no EXPR. +Returns the number of seconds actually slept. + May be interrupted if the process receives a signal such as C<SIGALRM>. -Returns the number of seconds actually slept. You probably cannot -mix C<alarm> and C<sleep> calls, because C<sleep> is often implemented -using C<alarm>. + + eval { + local $SIG{ALARM} = sub { die "Alarm!\n" }; + sleep; + }; + die $@ unless $@ eq "Alarm!\n"; + +You probably cannot mix C<alarm> and C<sleep> calls, because C<sleep> +is often implemented using C<alarm>. On some older systems, it may sleep up to a full second less than what you requested, depending on how it counts seconds. Most modern systems -- Michael G Schwern schwern@pobox.com http://www.pobox.com/~schwern/ Cuius rei demonstrationem mirabilem sane detexi hanc subscriptis exiguitas non caperet.