in reply to Why is this not dying

Well, of course. You just closed STDERR so anything printed to it will be lost. If you really want to go back to the original STDERR you will have to save a copy of the file handle, either using dup() or the equivalent "open" parameters. E.g.
open SAVEERR, ">&STDERR"; open STDERR, ">>err.log" or die "err.log: $!\n"; ... close STDERR; open STDERR, ">&SAVEERR";

Replies are listed 'Best First'.
Re: Re: Why is this not dying
by Anonymous Monk on Apr 02, 2003 at 21:08 UTC
    Thanks ever so much. Your reply was part of the solution. Interestingly, the reason why the die was never executed (much less displayed anywhere) was because of an apparent race condition(?) between writing to the err.log and testing its size. In the following if (-z...) conditional, a print "you missed errlog size" statement would be printed, despite the fact that a check afterwards showed that err.log contained the lines I was expecting for the test case. A bit of sleep chicanery was required. So this works as desired:
    open SAVERR, ">&STDERR"; open STDERR, ">>err.log"; # Perl can run the shell # if (open(PIPE, "$cmd <$tempfile |")) { sleep(2); if (-z './err.log') { close SAVERR; process(*PIPE); } # but there is a message in STDERR # else { # print LOG "ERROR: see err.log, exiting...\n"; # close STDERR; open STDERR, ">&SAVERR"; die "Killed.\n"; } }