I was asked in a private message the purpose of localizing $! in the reap_kids() routine, and would just as soon reply to my original post to describe it for the benefit of others.

The $! variable (defined here in the perlvar docs) holds what C programmers know as the errno status. This (possibly) holds information about the last system call failure.

In Perl code that makes system calls and wishes to track or report on the specific types of errors such calls may return, it is necessary to localize Perl's $! variable. You can read more about how exactly local works by reading about Temporary Values via local() from the perlsub docs.

In my earlier code example, it's necessary for the SIGCHLD signal handler to localize this in case the main code loop is busy doing something that (might) use this variable. Without the signal handling keeping its own temporary copy, the value could change which would alter the behavior of the main code. Generally any signal handler should localize the global punctuation variables changed, either explicitly (like $/) or implicitly (like $! discussed here.)


In reply to Re^2: How to make parent wait for all the child processes. by Apero
in thread How to make parent wait for all the child processes. by gjoshi

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.