reply to your update:

My advice is to report the problem and let the porters decide if it is a bug or not. system already protects itself against other signals, and probably the infrastructure to filter some pids from wait already exists in order to handle asynchronous processes created by open FOO, '|-', ....

In the meantime...

sub mysystem { my $signal_received = 0; my $old_signal_handler = $SIG{CHLD}; local $SIG{CHLD} = sub { $signal_received = 1}; system @_; $old_signal_handler->() if $signal_received; }
And inside your signal handler ensure that $! and $? are localized, so that the values of this globals don't get unexpectedly changed at any place in your program.

In reply to Re: system() returns -1 with $SIG{CHLD}? by salva
in thread system() returns -1 with $SIG{CHLD}? by cmv

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.