I wonder if I am misreading something, but I believe I have found a bug in Carp. My development group regularly uses exit status to report error conditions to parent programs. This is because we do TN3270 screen scraping and certain conditions (host timeout, connection refused, etc.) cause an automatic restart of the programs. When we began moving our programs to perl, the restarting stopped working. After some searching, I found the problem was Carp. I have found this problem in both 5.6.1 and 5.8.1.

Compare the two snippets and their outputs.

Using die:
#!/appl/cpc/bin/perl -w use strict; use warnings; $! = 10; $? = 9; die "$!: $?";

xxx:xxx/xxx/xxx> perl5.8.1 test.pl; echo $?
No child processes: 9 at test.pl line 7.
10

Using croak:
#!/appl/cpc/bin/perl -w use strict; use warnings; use Carp; $!=10; $?=9; croak "$!: $?";

xxx:/xxx/xxx/xxx> perl5.8.1 test.pl; echo $?
No child processes: 9 at test.pl line 9
255

Scanning through the code for Carp, I can't (offhand) see anything that might be causing this. I vaguely suspect this from Carp.pm:
{ local $@; require Carp::Heavy; } # XXX fix require to not clear $ +@?

But those suspicions are mostly because I have no clue and am grasping at anything that looks vaguely weird. Is this a valid bug to report or am I missing something?

For reference, this is compiled for 'HP-UX B.11.00 E'. I can post the 'perl -V' if necessary.


In reply to Bug with Carp and $!/$? by Kageneko

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.