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


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

in Table To:


© 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