I have an all perl version of FCGI that I made for work called ACGI... seems to work fine. However. I have an ACGI instance that forks child processes, and I put in code to check their exit values using waitpid and $?

When I have freshly started the ACGI, the first waitpid says the exit value was 0 (should be 1), all subsequent waitpids return 255 (should be 0). Any time after that they are all 255

As far as I see there are no end blocks screwing up the value, and an END block I specially put in at the end shows the proper exit values

The ACGI code that I am running is itself a child of a parent ACGI process, so I am thinking that maybe the dual level of forks is the problem, but it doesn't seem that it should be. But as the tests below show, the outer fork does seem to confuse the issue

The box in question is solaris 2.7, with perl 5.6.1...

UPDATE My bad on the test code... see bluto's messages... still have the real problem, tho. The following example is useless

when I run the following one-liner
perl -e 'if(fork){if(fork){waitpid(-1,undef);print"-- ",$?>>8,"\n";}else{exit 4}}'
I get random responses... either 4 or 0... no pattern.

On my debian box with 5.8.2, I always get 4...

and on my redhat box at work with 5.8.0 I always get 0...

Am I going crazy? Did I find a bug? Can I make this work somehow?

UPDATE

ARGH! There WAS and END block and it had system calls in it... damn legacy code full of requires...

                - Ant
                - Some of my best work - (1 2 3)


In reply to Waitpid Woes by suaveant

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.