use strict; use warnings; use POSIX; if (my $pid = fork) { sleep 1; alarm 10; kill (POSIX::SIGUSR2, $pid); $SIG{CHLD} = 'IGNORE'; while( wait() != -1 ){ print STDERR "wait\n"}; } else { $SIG{USR2} = sub { print "CHILD $$ EXIT\n"; exit(1); }; sleep 1 while (1); } print STDERR "DONE\n";

This code dies with ALARM, only on OpenBSD, only on Perl 5.12.x. (installed with perlbrew)

And it usually works well with openbsd vendor perl 5.12.2:

Locally applied patches: CVE-2010-0405 Updated CGI to 3.51 Updated Test::Simple to 0.98 Updated List::Util to 1.23 CVE-2011-1487 Updated Digest to 1.17 CVE-2011-2939 uncommitted-changes

Note that $SIG{CHLD} = 'IGNORE'; is a special perl feature to auto-reap zombies (i.e. it acts as calling wait() in signal handler), however replacing $SIG{CHLD} = 'IGNORE' with:

$SIG{CHLD} = sub { while( wait() != -1 ){ print STDERR "wait0\n"}; };
fixes problem

I am wondering is this a bug or feature and mixing wait() in signal handlers and wait() in main code is bad idea?


In reply to SIG CHLD IGNORE and wait at same time by vsespb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.