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";
}
}