Perldoc Search: "$SIG" perl-5.20.1

search official POD


12 PODs, 61 LINEs found.
perlipc.pod
15 :             my $signame = shift;
17 :             die "Somebody sent me a SIG$signame";
19 :         $SIG{INT} = __PACKAGE__ . "::catch_zap";  
20 :         $SIG{INT} = \&catch_zap;  # best strategy
28 :     On most Unix platforms, the "CHLD" (sometimes also known as "CLD") signal has special behavior with respect to a value of "IGNORE". Setting $SIG{CHLD} to "IGNORE" on such a platform has the effect of not creating zombie processes when the parent process fails to "wait()" on its child processes (i.e., child processes are automatically reaped). Calling "wait()" with $SIG{CHLD} set to "IGNORE" usually returns -1 on such platforms.
32 :     Sending a signal to a negative process ID means that you send the signal to the entire Unix process group. This code sends a hang-up signal to all processes in the current process group, and also sets $SIG{HUP} to "IGNORE" so it doesn't kill itself:
36 :             local $SIG{HUP} = "IGNORE";
55 :         $SIG{INT} = sub { die "\nOutta here!\n" };
60 :         $SIG{CHLD} = sub {
75 :         $SIG{CHLD} = sub {
104 :             local $SIG{ALRM} = sub { die $ALARM_EXCEPTION };
136 :       $SIG{HUP} = sub {
174 :         Instead of setting $SIG{ALRM}:
176 :            local $SIG{ALRM} = sub { die "alarm" };
245 :         local $SIG{PIPE} = sub { die "spooler pipe broke" };
281 :         $SIG{PIPE} = "IGNORE";
372 :         $SIG{PIPE} = sub { die "whoops, $program pipe broke" };
633 :         $SIG{CHLD} = \&REAPER;
683 :             $SIG{CHLD} = \&REAPER;  # loathe SysV
686 :         $SIG{CHLD} = \&REAPER;
831 :             $SIG{CHLD} = \&REAPER;  # loathe SysV
834 :         $SIG{CHLD} = \&REAPER;
perlvar.pod
250 :                     my($sig) = @_;
251 :                     print "Caught a SIG$sig--shutting down\n";
256 :                 $SIG{'INT'}  = \&handler;
257 :                 $SIG{'QUIT'} = \&handler;
259 :                 $SIG{'INT'}  = 'DEFAULT';   # restore default action
260 :                 $SIG{'QUIT'} = 'IGNORE';    # ignore SIGQUIT
266 :                 $SIG{"PIPE"} = "Plumber";   # assumes main::Plumber (not
268 :                 $SIG{"PIPE"} = \&Plumber;   # just fine; assume current
270 :                 $SIG{"PIPE"} = *Plumber;    # somewhat esoteric
271 :                 $SIG{"PIPE"} = Plumber();   # oops, what did Plumber()
280 :             Certain internal hooks can be also set using the %SIG hash. The routine indicated by $SIG{__WARN__} is called when a warning message is about to be printed. The warning message is passed as the first argument. The presence of a "__WARN__" hook causes the ordinary printing of warnings to "STDERR" to be suppressed. You can use this to save warnings in a variable, or turn warnings into fatal errors, like this:
282 :                 local $SIG{__WARN__} = sub { die $_[0] };
287 :                 local $SIG{__WARN__} = sub {};
289 :             The routine indicated by $SIG{__DIE__} is called when a fatal exception is about to be thrown. The error message is passed as the first argument. When a "__DIE__" hook routine returns, the exception processing continues as it would have in the absence of the hook, unless the hook routine itself exits via a "goto &sub", a loop exit, or a "die()". The "__DIE__" handler is explicitly disabled during the call, so that you can die from a "__DIE__" handler. Similarly for "__WARN__".
291 :             Due to an implementation glitch, the $SIG{__DIE__} hook is called even inside an "eval()". Do not use this to rewrite a pending exception in $@, or as a bizarre substitute for overriding "CORE::GLOBAL::die()". This strange action at a distance may be fixed in a future release so that $SIG{__DIE__} is only called if your program is about to exit, as was the original intent. Any other use is deprecated.
303 :             Having to even think about the $^S variable in your exception handlers is simply wrong. $SIG{__DIE__} as currently implemented invites grievous and difficult to track down errors. Avoid it and use an "END{}" or CORE::GLOBAL::die override instead.
871 :             The first state may happen in $SIG{__DIE__} and $SIG{__WARN__} handlers.
939 :             Warning messages are not collected in this variable. You can, however, set up a routine to process warnings by setting $SIG{__WARN__} as described in "%SIG".
perlfunc.pod
225 :                 local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required
705 :         You can arrange for a callback to be run just before the "die" does its deed, by setting the $SIG{__DIE__} hook. The associated handler is called with the error text and can change the error message, if it sees fit, by calling "die" again. See "%SIG" in perlvar for details on setting %SIG entries, and "eval BLOCK" for some examples. Although this feature was to be run only right before your program was to exit, this is not currently so: the $SIG{__DIE__} hook is currently called even inside eval()ed blocks/strings! If one wants the hook to do nothing in such situations, put
843 :         If there is a syntax error or runtime error, or a "die" statement is executed, "eval" returns "undef" in scalar context or an empty list in list context, and $@ is set to the error message. (Prior to 5.16, a bug caused "undef" to be returned in list context for syntax errors, but not for runtime errors.) If there was no error, $@ is set to the empty string. A control flow operator like "last" or "goto" can bypass the setting of $@. Beware that using "eval" neither silences Perl from printing warnings to STDERR, nor does it stuff the text of warning messages into $@. To do either of those, you have to use the $SIG{__WARN__} facility, or turn off warnings inside the BLOCK or EXPR using "no warnings 'all'". See "warn", perlvar, and warnings.
863 :         Using the "eval{}" form as an exception trap in libraries does have some issues. Due to the current arguably broken state of "__DIE__" hooks, you may wish not to trigger any "__DIE__" hooks that user code may have installed. You can use the "local $SIG{__DIE__}" construct for this purpose, as this example shows:
866 :             eval { local $SIG{'__DIE__'}; $answer = $a / $b; };
873 :                local $SIG{'__DIE__'} =
1149 :         If you "fork" without ever waiting on your children, you will accumulate zombies. On some systems, you can avoid this by setting $SIG{CHLD} to "IGNORE". See also perlipc for more examples of forking and reaping moribund children.
3323 :                 local $SIG{ALARM} = sub { die "Alarm!\n" };
4825 :         If you use wait in your handler for $SIG{CHLD} it may accidentally for the child created by qx() or system(). See perlipc for details.
4862 :         No message is printed if there is a $SIG{__WARN__} handler installed. It is the handler's responsibility to deal with the message as it sees fit (like, for instance, converting it into a "die"). Most handlers must therefore arrange to actually display the warnings that they are not prepared to deal with, by calling "warn" again in the handler. Note that this is quite safe and will not produce an endless loop, since "__WARN__" hooks are not called from inside one.
4864 :         You will find this behavior is slightly different from that of $SIG{__DIE__} handlers (which don't suppress the error text, but can instead call "die" again to change it).
4869 :             BEGIN { $SIG{'__WARN__'} = sub { warn $_[0] if $DOWARN } }
perlport.pod
949 :             "kill()" doesn't have the semantics of "raise()", i.e. it doesn't send a signal to the identified process like it does on Unix platforms. Instead "kill($sig, $pid)" terminates the process identified by $pid, and makes it exit immediately with exit status $sig. As in Unix, if $sig is 0 and the specified process exists, it returns true without actually terminating it. (Win32)
perlvms.pod
297 :         In most cases, "kill" is implemented via the undocumented system service $SIGPRC, which has the same calling sequence as $FORCEX, but throws an exception in the target process rather than forcing it to call $EXIT. Generally speaking, "kill" follows the behavior of the CRTL's "kill()" function, but unlike that function can be called from within a signal handler. Also, unlike the "kill" in some versions of the CRTL, Perl's "kill" checks the validity of the signal passed in and returns an error rather than attempting to send an unrecognized signal.
perlhack.pod
260 :     *   Promote unforeseen warnings to errors with $SIG{__WARN__}.
perldebug.pod
539 :     If you're in a slow syscall (like "wait"ing, "accept"ing, or "read"ing from your keyboard or a socket) and haven't set up your own $SIG{INT} handler, then you won't be able to CTRL-C your way back to the debugger, because the debugger's own $SIG{INT} handler doesn't understand that it needs to raise an exception to longjmp(3) out of slow syscalls.
perlsub.pod
790 :                 local $SIG{INT} = 'IGNORE';
perldiag.pod
19 :     Optional warnings are enabled by using the "warnings" pragma or the -w and -W switches. Warnings may be captured by setting $SIG{__WARN__} to a reference to a routine that will be called on each warning instead of printing it. See perlvar.
perldebtut.pod
537 :             BEGIN { $SIG{__DIE__} = sub { require Carp; Carp::confess(@_) } }
perlmod.pod
16 :     "eval"ed strings are compiled in the package in which the eval() was compiled. (Assignments to $SIG{}, however, assume the signal handler specified is in the "main" package. Qualify the signal handler name if you wish to have a signal handler in a package.) For an example, examine perldb.pl in the Perl library. It initially switches to the "DB" package so that the debugger doesn't interfere with variables in the program you are trying to debug. At various points, however, it temporarily switches back to the "main" package to evaluate various expressions in the context of the "main" package (or wherever you came from). See perldebug.
perlpacktut.pod
298 :        ($carry, undef, $parity, undef, $auxcarry, undef, $zero, $sign,
<< Back to Perldoc Search