I have a very dense perl script that forks. The child does all the work and the parent waits for it to finish and emails you if it failed. Essentially it does:
<code> if ( WIFEXITED($?)
{
my $exitcode=WEXITSTATUS($?);
exit 0 unless $exitcode;
}
else
{
<send the email>
}
</code>
<code> if ( WIFEXITED($?)
{
my $exitcode=WEXITSTATUS($?);
exit 0 unless $exitcode;
}
else
{
<send the email>
}
</code>
if ( WIFEXITED($?)
{
my $exitcode=WEXITSTATUS($?);
exit 0 unless $exitcode;
}
else
{
<send the email>
}
I’ve printed $exitcode to stderr and it is 0 but somehow the else block is still executing. Is that possible? If the child exited zero shouldn’t the if block be executing?