in reply to BUG! die() executing outside scope of eval block
Could it be the other way around? I see that you're switching off the alarm outside of the eval. Maybe you should switch off the alarm inside the SIGCHLD handler:
Another approach would be to return to using unsafe signal handlers inside the eval, see POSIX's sigaction() for that.-local $SIG{'CHLD'} = sub { die("CHLD EVENT\n"); }; +local $SIG{'CHLD'} = sub { alarm(0); die("CHLD EVENT\n"); };
Liz
Update:
Actually, Perl 5.8.1 introduced a new idiom for temporarily allowing unsafe signals:
From perl581delta.pod:local $ENV{PERL_SIGNALS} = 'unsafe';
However, the new safer model has its problems too. Because now an opcode, a basic unit of Perl execution, is never interrupted but instead let to run to completion, certain operations that can take a long time now really do take a long time. For example, certain network operations have their own blocking and timeout mechanisms, and being able to interrupt them immediately would be nice.
Therefore perl 5.8.1 introduces a "backdoor" to restore the pre-5.8.0 (pre-5.7.3, really) signal behaviour. Just set the environment vari- able PERL_SIGNALS to "unsafe", and the old immediate (and unsafe) sig- nal handling behaviour returns. See "PERL_SIGNALS" in perlrun and "Deferred Signals (Safe Signals)" in perlipc.
In completely unrelated news, you can now use safe signals with POSIX::SigAction. See "POSIX::SigAction" in POSIX.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: BUG? die() executing outside scope of eval block
by jdhedden (Deacon) on Dec 19, 2003 at 13:25 UTC |