Did you even look at the example I gave?

I used wait. I knew which child exited. All that the WNOHANG flag could have added is cause to tie up the CPU in a tight loop. And getting the right value would give you reason to load POSIX, which both slows down the code and makes it less portable!

And for the record I was not telling people to use wait instead of waitpid. I was telling you that you are wrong when you say that wait is deprecated and particularly dangerous.

Ironically not only is wait not dangerous when used correctly, but your advice all presumes that the programmer will use signals. In fact cautious programmers have read the documentation, see the warnings, and avoid signals in Perl. Your giving any advice based on your theories of how to write good signals is encouraging a practice that is dangerous in Perl.

Not only that, but the fact that you get a more complex signal handler can cause its own problems. perlipc offers two signal handlers. You and Stevens blast the one that uses wait based on how a safe handler in C should be written. But it is unclear that the waitpid handler is any better. It is more complex, you spend more time in the handler (when any signal will crash you), and the fact that you are assigning to a hash means that eventually you may wind up having a malloc() happen behind your back which would probably cause you to dump core!

Personally I just skip down to the big WARNING section, take that to heart and avoid both of them!


In reply to RE (tilly) 6: For all your forking needs.. by tilly
in thread For all your forking needs.. by reyjrar

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.