I cannot find a single correct statement in your post, even after careful testing of each point you make, so I have to assume you are a poseur who intends to disrupt and disinform the audience.

Update: For example, if ($child) will likely be undef, so what? it doesn't yield a warning. Its easy enough to test my code by putting a print statement for each section. If you comment out the exit, a print statement after the if block gets executed twice as I advertised. If you put sleep 12 in the "job processing section" it will execute the loop a couple of times for clarity.

Update+:

#!/usr/bin/perl use POSIX ":sys_wait_h"; my $child = fork; if ($child) { # parent case my $res; while (not ($res = waitpid($child, WNOHANG))) { sleep 5; # check file list here # ... print "checking file list\n"; } if ($res == -1) { warn "fatal child error\n"; exit; } } else { # child case # insert job processing here print "job processing\n"; sleep 12; exit; # comment this out to see how many times the final print occ +urs if you don't exit." # child must explicitly exit otherwise both would continue executing t +his } print "Past the if\n";
update++: produces this with exit in place
job processing checking file list checking file list checking file list Past the if
and this with exit removed:
job processing checking file list checking file list Past the if checking file list Past the if

One world, one people


In reply to Re^3: Doing every X seconds by anonymized user 468275
in thread Doing every X seconds by dideod.yang

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.