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

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

Thread Previous
From:
Jesse Luehrs via RT
Date:
June 26, 2012 16:52
Subject:
[perl #110292] __WARN__ handler disabled if caught signal received in this handler
Message ID:
rt-3.6.HEAD-28836-1340754720-1045.110292-15-0@perl.org
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;
      wait;
  }
  else {
      sleep 5;
  }

This prints:

  inner: outer: caught USR1 at test.pl line 14.
  caught USR2 at test.pl 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.

-doy

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org:443/rt3/Ticket/Display.html?id=110292

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About