Basic HTML version of Foils prepared Sept 20 97

Foil 74 Signals, Interrupt Handlers, kill

From Tutorial on PERL Computational Science for Information Age Course CPS616 -- Sept 20 97. by Geoffrey C. Fox,Nancy McCracken,Tom Scavo


The hash %SIG is used to define signal handlers (subroutines) used for various signals
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:
$SIG{'INT'} = 'handler';
sub handler { # First argument is signal name
  • my($sig) = @_;
  • print("Signal $sig received -- shutting down\n");
  • exit(0);
}
kill $signum, $child1, $child2; # sends interrupt $signum to process numbers stored in $child1 and $child2
$signum is NUMERICAL label (2 for SIGINT) and $child1,2 the child process number as returned by fork or open(PROCESSHANDLE,..) to parent



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sun Sep 21 1997