develooper Front page | perl.perl5.porters | Postings from June 2008

[perl #24174] perl-5.8.0-55 exit bug

Thread Previous
From:
Steve Peters via RT
Date:
June 23, 2008 11:28
Subject:
[perl #24174] perl-5.8.0-55 exit bug
Message ID:
rt-3.6.HEAD-6656-1214240190-706.24174-15-0@perl.org
On Mon Oct 13 11:06:18 2003, schwern wrote:
> 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
> 
> 


Thanks!  I applied your patch as change #34080.  Almost five years
later, but it still applied.

Steve Peters

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About