I have a bit of a chewy problem which has been giving me a headache all morning.

I've got a script which fork/execs child process which are then of no concern to the parent. I had this running fine apart from the children leaving themselves as zombies once they had completed.
After a quick read of the Cookbook I put in:
$SIG{CHLD} = "IGNORE";

Problem solved I thought, no more zombies and all is good in the world.
However when I reran the script I got the following messages:
glob failed (child exited with status -1, core dumped) at ./FeedsMonit +or.pl line 293 <_GEN_0> chunk 1.
I got three of these messages, 1 for each glob() in the script and with various chunk numbers. The globs themselves were still returning the right result but the messages were causing havoc as they went to the console even though this was running in background and with STDOUT and STDERR redirected to a logfile.
After doing more digging I found that glob() shells out to run itself. Therefore this is a child process and ignoring child signals seems to be causing the problem. Take the IGNORE out and back come the zombies but the messages go.
I've thought of reenabling the child signal handler to DEFAULT around the globs as below:
$SIG{CHLD}="DEFAULT"; @x = glob($globLine); $SIG(CHLD)="IGNORE";
However sooner or later one of my child processes is going to finish just a glob runs and will zombie itself.
Can anyone come up with a nice clean solution to this? I've not got a great deal of process/signal handling experience so any advice would be appreciated.

In reply to Ingoring Child Processes And glob() by barndoor

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.