An excellent example that makes it pretty clear what is going on, thanks. I am still puzzled though, the die runs in the child but how did the die get in there ? Is open3 forking and if so how does it decide to run the die but not the following print which comes only from the parent. Is there any way in the parent to trap failure of the child ?
# here the die runs in the child:
nph>perl -MIPC::Open3 -le'print "dad: $$";eval {$pid = open3(*IN, *OUT
+, *ERR, @ARGV);}; die "$$ ACK $@\n" if ($@);print <ERR>' nosuch
dad: 62718
55596 ACK open3: exec of nosuch failed at -e line 1
# yet here in the same code it runs in the parent !!!
nph>perl -MIPC::Open3 -le'print "dad: $$";eval {$pid = open3(*IN, *OUT
+, *ERR, @ARGV);}; die "$$ ACK $@\n" if ($@);print <ERR>'
dad: 25600
25600 ACK open3(*main::IN, *main::OUT, *main::ERR): not enough argumen
+ts at -e line 1
# and if I remove the print <ERR> I alter the behaviour again
nph>perl -MIPC::Open3 -le'print "dad: $$";eval {$pid = open3(*IN, *OUT
+, *ERR, @ARGV);}; die "$$ ACK $@\n" if ($@);print "moo" ' nosuch
dad: 55592
moo
nph>
Thanks,
R.
Pereant, qui ante nos nostra dixerunt!