Clownburner has asked for the wisdom of the Perl Monks concerning the following question:
..But it doesn't work. As soon as the code hits the line where I assign a handler to $SIG{QUIT}, it runs that subroutine and exits. But if I do this:sub GotSignal($) { my $sig = shift; print "Got a $sig signal, exiting\n"; exit(0); } # Install signal handlers local $SIG{HUP} = 'IGNORE'; local $SIG{QUIT} = \&GotSignal('quit'); while (1) { # do stuff }
The second example works as expected. This is on Linux (RH 6.2) runing perl5 (5.0 patchlevel 5 subversion 3). Anyone have any ideas? All help appreciated.# Install signal handlers local $SIG{HUP} = 'IGNORE'; local $SIG{QUIT} = sub { my $sig = shift; print "Got a $sig sign +al, exiting\n"; exit(0); }; while (1) { # do stuff }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: Strange SIGNAL HANDLER behavior...
by tye (Sage) on Oct 24, 2001 at 23:32 UTC | |
|
Re: Strange SIGNAL HANDLER behavior...
by dws (Chancellor) on Oct 24, 2001 at 23:07 UTC | |
by Clownburner (Monk) on Oct 24, 2001 at 23:41 UTC | |
by VSarkiss (Monsignor) on Oct 24, 2001 at 23:59 UTC |