in reply to forked die() in eval block has counterintuitive behavior?
#!/usr/bin/perl -w use strict; my $num = '123'; # an external database ID, for example warn "(PID $$) Beginning transaction #$num "; eval { my $pid = fork(); if ($pid) { warn "\t(PID $$) the parent does OK"; } else { eval { warn "\t(PID $$) the child fails"; die "\t(PID $$) Child process failure"; }; warn $@ if $@; exit; } }; if ($@) { warn "(PID $$) Rolling back transaction #$num: died in eval with $ +@"; } else { warn "(PID $$) Committing transaction #$num"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: forked die() in eval block has counterintuitive behavior?
by rlucas (Scribe) on May 24, 2005 at 12:55 UTC |