... if I find an answer I'll report back here.

The answer was that in some cases the scripts were being run manually by people, and often this would be done by:

  1. running the scripts
  2. sending them into the background
  3. the people logging back out again at which point STDOUT and STDERR were closed.

When the child process then tried to write to STDOUT/STDERR the non-zero exit code would result.

I've not fully unravelled this thread to the root cause - but it is something that does not happen in older debian releases (though when the change happened I'm not sure).

The solution is either to avoid writing to closed STDOUT/STDERRs (but that's fiddly/fragile across a lot of code) or better and simpler to redirect the output of processes that are going to be backgrounded using something like '>/dev/null 2>&1' or nohup which also redirects STDOUT/STDERR.

If the output is needed for some time then probably the easiest approach is to launch the process in a terminal manager like screen/tmux for the duration of the run.


In reply to Re: system >> 8 is non-zero when child exits with exit(0) by bjdean
in thread system >> 8 is non-zero when child exits with exit(0) by bjdean

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.