On Mon, 29 Nov 2004 17:16:31 -0500, Stas Bekman <[EMAIL PROTECTED]> wrote:
> Jeff Trawick wrote:
> 
> > How is SIGALRM used specifically?
> 
> e.g.:
>          eval {
>              POSIX::sigaction(SIGALRM,
>                               POSIX::SigAction->new(sub { die "alarm" }))
>                    or die "Error setting SIGALRM handler: $!\n";
>              alarm 2;
>              potentially_long_running_process()
>              alarm 0;
>          };
>          do_something() if $@ && $@ =~ /alarm/;

no, can't do that, unless you're the only thread in the process that
does anything like that since

1) any other code in the process can wipe out your SIGALRM handler
2) only one "alarm" per process

> > Is there some thread-aware service which works sort of like the 
> > thread-unaware alarm()
> > call which will send SIGALRM to a specific thread?
> 
> Nope. but if the signal is sent by the same thread that catches it, it's
> still not guaranteed that it'll get it?

the SIGALRM signal sent due to a call to alarm() is sent by the
kernel; no guarantee which thread will get it, unless there is only
one thread which doesn't have SIGALRM blocked

Reply via email to