in reply to Weird use warnings FATAL behavior

Hmmm, look at this...

use warnings FATAL => qw(all); eval { open(CMD, "_bad_exe_ a b c|") or die "does not happen" }; die "die \$\@ ERROR: $@\n"; while(<CMD>){} __END__ die $@ ERROR: Can't exec "_bad_exe_": No such file or directory at ... + line x. die $@ ERROR:

How did that happen?

This is perl, v5.8.8 built for x86_64-linux-gnu-thread-multi

Replies are listed 'Best First'.
Re^2: Weird use warnings FATAL behavior (expected)
by tye (Sage) on Mar 18, 2008 at 06:05 UTC

    It looks like the child process tries to warn which gets turned into a die which gets caught by the eval and thus causes the child to continue on to the line after the eval instead of doing what it was planning to do after it warned.

    Not really that much of a surprise, IMHO, since you told it to do all of those things.

    Then the parent doesn't get tricky notice of the child being unable to exec (since you forced the child to get side-tracked) so open succeeds and the parent continues on from there.

    One bug is that $$ doesn't get updated since the forked code isn't expected to survive long enough to be able to run any Perl code that uses $$, so trying to report $$ just confuses things.

    - tye        

      One bug is that $$ doesn't get updated since the forked code isn't expected to survive long enough to be able to run any Perl code that uses $$

      aha! The last bit of the puzzle. I assumed reading $$ translated into a system call to fetch the PID. It never occured to me it might not be accurate.