home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / perl5 / sigtrap.z / sigtrap
Encoding:
Text File  |  1998-10-30  |  7.6 KB  |  199 lines

  1.  
  2.  
  3.  
  4. ssssiiiiggggttttrrrraaaapppp((((3333))))                                                          ssssiiiiggggttttrrrraaaapppp((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      sigtrap - Perl pragma to enable simple signal handling
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.          use sigtrap;
  13.          use sigtrap qw(stack-trace old-interface-signals);  # equivalent
  14.          use sigtrap qw(BUS SEGV PIPE ABRT);
  15.          use sigtrap qw(die INT QUIT);
  16.          use sigtrap qw(die normal-signals);
  17.          use sigtrap qw(die untrapped normal-signals);
  18.          use sigtrap qw(die untrapped normal-signals
  19.                          stack-trace any error-signals);
  20.          use sigtrap 'handler' => \&my_handler, 'normal-signals';
  21.          use sigtrap qw(handler my_handler normal-signals
  22.                          stack-trace error-signals);
  23.  
  24.  
  25. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  26.      The ssssiiiiggggttttrrrraaaapppp pragma is a simple interface to installing signal handlers.
  27.      You can have it install one of two handlers supplied by ssssiiiiggggttttrrrraaaapppp itself
  28.      (one which provides a Perl stack trace and one which simply die()s), or
  29.      alternately you can supply your own handler for it to install.  It can be
  30.      told only to install a handler for signals which are either untrapped or
  31.      ignored.  It has a couple of lists of signals to trap, plus you can
  32.      supply your own list of signals.
  33.  
  34.      The arguments passed to the use statement which invokes ssssiiiiggggttttrrrraaaapppp are
  35.      processed in order.  When a signal name or the name of one of ssssiiiiggggttttrrrraaaapppp's
  36.      signal lists is encountered a handler is immediately installed, when an
  37.      option is encountered it affects subsequently installed handlers.
  38.  
  39. OOOOPPPPTTTTIIIIOOOONNNNSSSS
  40.      SSSSIIIIGGGGNNNNAAAALLLL HHHHAAAANNNNDDDDLLLLEEEERRRRSSSS
  41.  
  42.      These options affect which handler will be used for subsequently
  43.      installed signals.
  44.  
  45.      ssssttttaaaacccckkkk----ttttrrrraaaacccceeee
  46.          The handler used for subsequently installed signals outputs a Perl
  47.          stack trace to STDERR and then tries to dump core.  This is the
  48.          default signal handler.
  49.  
  50.      ddddiiiieeee The handler used for subsequently installed signals calls die
  51.          (actually croak) with a message indicating which signal was caught.
  52.  
  53.      hhhhaaaannnnddddlllleeeerrrr _y_o_u_r-_h_a_n_d_l_e_r
  54.          _y_o_u_r-_h_a_n_d_l_e_r will be used as the handler for subsequently installed
  55.          signals.  _y_o_u_r-_h_a_n_d_l_e_r can be any value which is valid as an
  56.          assignment to an element of %SIG.
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. ssssiiiiggggttttrrrraaaapppp((((3333))))                                                          ssssiiiiggggttttrrrraaaapppp((((3333))))
  71.  
  72.  
  73.  
  74.      SSSSIIIIGGGGNNNNAAAALLLL LLLLIIIISSSSTTTTSSSS
  75.  
  76.      ssssiiiiggggttttrrrraaaapppp has a few built-in lists of signals to trap.  They are:
  77.  
  78.      nnnnoooorrrrmmmmaaaallll----ssssiiiiggggnnnnaaaallllssss
  79.          These are the signals which a program might normally expect to
  80.          encounter and which by default cause it to terminate.  They are HUP,
  81.          INT, PIPE and TERM.
  82.  
  83.      eeeerrrrrrrroooorrrr----ssssiiiiggggnnnnaaaallllssss
  84.          These signals usually indicate a serious problem with the Perl
  85.          interpreter or with your script.  They are ABRT, BUS, EMT, FPE, ILL,
  86.          QUIT, SEGV, SYS and TRAP.
  87.  
  88.      oooolllldddd----iiiinnnntttteeeerrrrffffaaaacccceeee----ssssiiiiggggnnnnaaaallllssss
  89.          These are the signals which were trapped by default by the old
  90.          ssssiiiiggggttttrrrraaaapppp interface, they are ABRT, BUS, EMT, FPE, ILL, PIPE, QUIT,
  91.          SEGV, SYS, TERM, and TRAP.  If no signals or signals lists are passed
  92.          to ssssiiiiggggttttrrrraaaapppp, this list is used.
  93.  
  94.      For each of these three lists, the collection of signals set to be
  95.      trapped is checked before trapping; if your architecture does not
  96.      implement a particular signal, it will not be trapped but rather silently
  97.      ignored.
  98.  
  99.      OOOOTTTTHHHHEEEERRRR
  100.  
  101.      uuuunnnnttttrrrraaaappppppppeeeedddd
  102.          This token tells ssssiiiiggggttttrrrraaaapppp to install handlers only for subsequently
  103.          listed signals which aren't already trapped or ignored.
  104.  
  105.      aaaannnnyyyy This token tells ssssiiiiggggttttrrrraaaapppp to install handlers for all subsequently
  106.          listed signals.  This is the default behavior.
  107.  
  108.      _s_i_g_n_a_l
  109.          Any argument which looks like a signal name (that is, /^[A-Z][A-Z0-
  110.          9]*$/) indicates that ssssiiiiggggttttrrrraaaapppp should install a handler for that name.
  111.  
  112.      _n_u_m_b_e_r
  113.          Require that at least version _n_u_m_b_e_r of ssssiiiiggggttttrrrraaaapppp is being used.
  114.  
  115. EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
  116.      Provide a stack trace for the old-interface-signals:
  117.  
  118.          use sigtrap;
  119.  
  120.      Ditto:
  121.  
  122.          use sigtrap qw(stack-trace old-interface-signals);
  123.  
  124.      Provide a stack trace on the 4 listed signals only:
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. ssssiiiiggggttttrrrraaaapppp((((3333))))                                                          ssssiiiiggggttttrrrraaaapppp((((3333))))
  137.  
  138.  
  139.  
  140.          use sigtrap qw(BUS SEGV PIPE ABRT);
  141.  
  142.      Die on INT or QUIT:
  143.  
  144.          use sigtrap qw(die INT QUIT);
  145.  
  146.      Die on HUP, INT, PIPE or TERM:
  147.  
  148.          use sigtrap qw(die normal-signals);
  149.  
  150.      Die on HUP, INT, PIPE or TERM, except don't change the behavior for
  151.      signals which are already trapped or ignored:
  152.  
  153.          use sigtrap qw(die untrapped normal-signals);
  154.  
  155.      Die on receipt one of an of the nnnnoooorrrrmmmmaaaallll----ssssiiiiggggnnnnaaaallllssss which is currently
  156.      uuuunnnnttttrrrraaaappppppppeeeedddd, provide a stack trace on receipt of aaaannnnyyyy of the eeeerrrrrrrroooorrrr----ssssiiiiggggnnnnaaaallllssss:
  157.  
  158.          use sigtrap qw(die untrapped normal-signals
  159.                          stack-trace any error-signals);
  160.  
  161.      Install _m_y__h_a_n_d_l_e_r() as the handler for the nnnnoooorrrrmmmmaaaallll----ssssiiiiggggnnnnaaaallllssss:
  162.  
  163.          use sigtrap 'handler', \&my_handler, 'normal-signals';
  164.  
  165.      Install _m_y__h_a_n_d_l_e_r() as the handler for the normal-signals, provide a
  166.      Perl stack trace on receipt of one of the error-signals:
  167.  
  168.          use sigtrap qw(handler my_handler normal-signals
  169.                          stack-trace error-signals);
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.