Basic HTML version of Foils prepared March 30 97

Foil 80 Signals, Interrupt Handlers, kill (Chapter 15 of Llama Book)

From PERL4 Tutorial for CPS616 Computational Science for Information Age Course CPS616 -- February 1995. by Geoffrey C. Fox


1 The associative array %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
  • local($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 Sat Sep 6 1997