I do get

Wed Feb 11 20:52:08 CET 2009 _lostChild args: $VAR1 = [ -1 ]; rc=0

Probably a matter of who calls wait() first... (i.e. system() or you in your signal handler).  Remember that signals are delivered asynchronously.

Update: an strace in my case shows:

... wait4(28813, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 28813 --- SIGCHLD (Child exited) @ 0 (0) --- rt_sigreturn(0) = 28813 rt_sigaction(SIGINT, {SIG_DFL}, NULL, 8) = 0 rt_sigaction(SIGQUIT, {SIG_DFL}, NULL, 8) = 0 read(6, "", 4) = 0 close(6) = 0 rt_sigprocmask(SIG_BLOCK, [CHLD], NULL, 8) = 0 wait4(-1, 0x7fff3bda0c04, 0, NULL) = -1 ECHILD (No child processe +s) write(1, "_lostChild args:\n", 17) = 17 write(1, "$VAR1 = [\n -1\n ]"..., 34) = 34 write(1, "\n", 1) = 1 rt_sigprocmask(SIG_UNBLOCK, [CHLD], NULL, 8) = 0 write(2, "rc=0\n", 5) = 5 close(4) = 0 exit_group(0) = ?

The first wait is from Perl's system(). Then the SIGCHLD is received, which leads to the next wait call from within the signal handler, which gets ECHILD, as the process has already been reaped by the previous system()'s wait...

In your case, the SIGCHLD presumably arrives a tad earlier (before the first wait).


In reply to Re: system() returns -1 with $SIG{CHLD}? by almut
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.