Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
OK, here is the expanded version of the original OP's oneliner, following tye's explanation:
cat #!/usr/bin/perl use strict; use warnings FATAL => 'all'; my $cmd = shift || '_bad_exe_ a b c'; print "I'm parent with id $$\n"; eval { my $pid = open CMD, "-|"; if ($pid) { print "I'm forking a child with id $pid\n"; print while <CMD>; } else { #no warnings; # get rid of warnings on "Can't exec:..." print "[$$] I'm child, about to exec [$cmd]\n"; exec $cmd; } }; die "[$$] ERROR: $@" if $@; print "[$$]HOW DID I GET HERE?\n";
Run with correct command (just as comparisson):
$ perl ls I'm parent with id 6238 I'm forking a child with id 6239 [6239] I'm child, about to exec [ls]
No problem there. Now, run with no args (default command):
$ perl I'm parent with id 6240 [6241] ERROR: Can't exec "_bad_exe_": No such file or directory at fat line 18. I'm forking a child with id 6241 [6241] I'm child, about to exec [_bad_exe_ a b c] [6240]HOW DID I GET HERE?
So I guess, it's the child that triggers the "Can't exec ..." warning that gets "upgraded" into fatal error (due to FATAL), trapped in $@, and dies. The child dies, the parent doesn't, that's HOW DID I GET HERE, I suppose. OTOH, if the no warnings; is uncommented, then well, no "Can't exec..." warning, no $@ trapping, and the child lives pretending nothing happens, yet covering up by asking HOW DID I GET HERE.

Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!

In reply to Re: Weird use warnings FATAL behavior by naikonta
in thread Weird use warnings FATAL behavior by jneil

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (7)
    As of 2018-03-22 16:55 GMT
    Find Nodes?
      Voting Booth?
      When I think of a mole I think of:

      Results (280 votes). Check out past polls.