develooper Front page | perl.perl5.porters | Postings from June 2012

[perl #110292] __WARN__ handler disabled if caught signal received in this handler

Thread Previous
Jesse Luehrs via RT
June 26, 2012 16:52
[perl #110292] __WARN__ handler disabled if caught signal received in this handler
Message ID:
I'm not sure this is really fixable - this is just how signals work.
Consider this slight modification of your script:

  $SIG{__WARN__} = sub {
      local $SIG{__WARN__} = sub {
          warn "inner: $_[0]";
          sleep 2;
      warn "outer: $_[0]";

  $SIG{USR1} = sub {
      warn "caught USR1";

  $SIG{USR2} = sub {
      warn "caught USR2";

  if (my $pid = fork) {
      kill USR1 => $pid;
      sleep 1;
      kill USR2 => $pid;
  else {
      sleep 5;

This prints:

  inner: outer: caught USR1 at line 14.
  caught USR2 at line 18.

Do you think the second warning should be "inner: outer: caught USR2" or
"inner: caught USR2"? How do you determine which warn handler to restore
during the execution of the signal? I think this is just another example
of the complications involved in using signals, and probably can't be
fixed in any sane way. If nobody points out anything dumb I'm missing,
I'll probably close this as wontfix in a while.


via perlbug:  queue: perl5 status: new

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About