204

Signal Handling
Defining a Signal Handler

  • A signal handler is defined by assigning to the built-in %SIG hash-table variable

    • Each %SIG key defines the signal number to catch

    • Each %SIG value is the subroutine which gets called

  • For example

      sub MySigInt { die "Sig INT caught!"; }
      $SIG{INT} = \&MySigInt;
      print "Running program...\n";
      while(1) {}