Hi,
There is an error in your code: you wrote system("prog2.pl") which does not invoke prog2.pl unless you have '.' (the current directory) in your PATH (which should be avoided).

By replacing your instruction with system("./prog2.pl") I get a return code of 5 both with and without SIGCHLD ignored. Just as I expected.

I expected this result because perl system emulates C system(3), and the man page of the latter states that:

During execution of the command, SIGCHLD will be blocked, and SIGINT and SIGQUIT will be ignored.

That is to say: system install its own SIGCHLD handler, which is needed exactly for capturing the exit status.

I join Abigail-II in asking which version of perl, operating system and kernel are you using.

By the way, why should ignoring SIGCHLD be recommended when using system? Never heard that...

Hoping this helps


Leo TheHobbit

In reply to Re: why does ignoring sigCHLD corrupt return value from system()? by TheHobbit
in thread why does ignoring sigCHLD corrupt return value from system()? by fiberhalo

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.