Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

perl SIGnal process

by chinaxing (Acolyte)
on Aug 08, 2013 at 08:03 UTC ( [id://1048510]=perlquestion: print w/replies, xml ) Need Help??

chinaxing has asked for the wisdom of the Perl Monks concerning the following question:

I exploit the %SIG hash, found most of values are "undef", some of are "IGNORE";

perl -MData::Dumper -E ' print Dumper \%SIG '

What confuse me is that, if SIGnal's process was set to undef,

how the signal will be processed when it come up ? ( ignore ? call the default action defined by OS ?)

BTW, if I want to set SIGPIPE 's handle to default; how can i to get it ?

$SIG{PIPE} = undef or $SIG{PIPE} = "" or #some thing else;
very thanks your patient to answer this :)

Replies are listed 'Best First'.
Re: perl SIGnal process
by betterworld (Curate) on Aug 08, 2013 at 12:00 UTC

    The operating system has its default ways to treat signals. Special application code is executed only if a signal handler is explicitly installed. If there is no handler, some default action will be taken, which should be documented. My system has informative man pages for "signal" in sections 7 and 2.

    Setting a signal to its default behavior is documented in perlvar:

    $SIG{'INT'} = 'DEFAULT'; # restore default action $SIG{'QUIT'} = 'IGNORE'; # ignore SIGQUIT
      thank you !

      but what's mean of undef , equals to 'DEFAULT' ? ;

      so does :
      $SIG{'INT'} = 'DEFAULT'
      equals to
      $SIG{'INT'} = undef
      ? very thanks your explaination :)
Re: perl SIGnal process
by kcott (Archbishop) on Aug 09, 2013 at 05:12 UTC

    G'day chinaxing,

    For further documentation, take a look at perlipc - Signals.

    For setting defaults, why not capture the starting values and then reapply the defaults if you need to:

    $ perl -Mstrict -Mwarnings -E ' my %default_signal_for = %SIG; say "*** Starting values ***"; say "SIG{USR1}: ", $SIG{USR1} // "<undef>"; say "DEF{USR1}: ", $default_signal_for{USR1} // "<undef>"; $SIG{USR1} = sub { 1 }; say "*** After setting USR1 ***"; say "SIG{USR1}: ", $SIG{USR1} // "<undef>"; say "DEF{USR1}: ", $default_signal_for{USR1} // "<undef>"; $SIG{USR1} = $default_signal_for{USR1}; say "*** Back to default values ***"; say "SIG{USR1}: ", $SIG{USR1} // "<undef>"; say "DEF{USR1}: ", $default_signal_for{USR1} // "<undef>"; ' *** Starting values *** SIG{USR1}: <undef> DEF{USR1}: <undef> *** After setting USR1 *** SIG{USR1}: CODE(0x7fa4008401b0) DEF{USR1}: <undef> *** Back to default values *** SIG{USR1}: <undef> DEF{USR1}: <undef>

    -- Ken

      yes!

      but i want to known difference between set to   'undef', "" and 'DEFAULT';

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1048510]
Approved by vinoth.ree
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-03-28 18:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found