in reply to Unsafe signals?
But that's probably not what you want.use vars '$flag'; $flag = 0; local $SIG{'TERM'} = sub { $flag = 1 } .... while (...) { ... die "got signal\n" if $flag; }
The reason is that the signal could have been receieved at any point, such as in a malloc(), so any code in your handler that might trigger a call to malloc() isn't safe. Even my code isn't completely safe, but is perhaps, less unsafe.
Dave.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Unsafe signals?
by cazz (Pilgrim) on Feb 23, 2005 at 17:09 UTC |