1 |
The hash %SIG is used to define signal handlers (subroutines) used for various signals
|
2 |
The keys of %SIG are the UNIX names with first SIG removed. For instance, to set handler() as routine that will handle SIGINT interrupts do something like:
|
3 |
$SIG{'INT'} = 'handler';
|
4 |
sub handler { # First argument is signal name
-
my($sig) = @_;
-
print("Signal $sig received -- shutting down\n");
-
exit(0);
|
5 |
}
|
6 |
kill $signum, $child1, $child2; # sends interrupt $signum to process numbers stored in $child1 and $child2
|
7 |
$signum is NUMERICAL label (2 for SIGINT) and $child1,2 the child process number as returned by fork or open(PROCESSHANDLE,..) to parent
|