<?xml version="1.0" encoding="windows-1252"?>
<node id="674749" title="Re: Weird use warnings FATAL behavior" created="2008-03-18 05:19:36" updated="2008-03-18 01:19:36">
<type id="11">
note</type>
<author id="607636">
naikonta</author>
<data>
<field name="doctext">
OK, here is the expanded version of the original OP's oneliner, following [tye]'s [id://674716|explanation]:

&lt;code&gt;
cat fatals.pl
#!/usr/bin/perl

use strict;
use warnings FATAL =&gt; '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 &lt;CMD&gt;;
    }
    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";
&lt;/code&gt;

Run with correct command (just as comparisson):

&lt;code&gt;
$ perl fatals.pl ls
I'm parent with id 6238
I'm forking a child with id 6239
[6239] I'm child, about to exec [ls]
642663.pl
642676.pl
642682.pl
644761.pl
&lt;/code&gt;

No problem there. Now, run with no args (default command):

&lt;code&gt;
$ perl fatals.pl
I'm parent with id 6240
[6241] ERROR: Can't exec "_bad_exe_": No such file or directory at fatals.pl 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?
&lt;/code&gt;

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 &lt;i&gt;HOW DID I GET HERE&lt;/i&gt;, I suppose. OTOH, if the &lt;c&gt;no warnings;&lt;/c&gt; is uncommented, then well, no "Can't exec..." warning, no $@ trapping, and the child lives pretending nothing happens, yet covering up by asking &lt;i&gt;HOW DID I GET HERE&lt;/i&gt;.

&lt;div class="pmsig"&gt;&lt;div class="pmsig-607636"&gt;
&lt;hr size="1" noshade="1"&gt;
&lt;p align="right"&gt;&lt;small&gt;
&lt;i&gt;Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!&lt;/i&gt;&lt;/small&gt;&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
674657</field>
<field name="parent_node">
674657</field>
</data>
</node>
