Subject: | forks the process if sendmail not found |
here is the code from MIME::Lite
====
my $pid = open SENDMAIL, "|-";
defined($pid) or die "open of pipe failed: $!\n";
if ( !$pid ) { ### child
exec(@cmd) or die "can't exec $p{Sendmail}: $!\n";
### NOTREACHED
} else { ### parent
$self->print( \*SENDMAIL );
close SENDMAIL || die "error closing $p{Sendmail}: $! (exit $?)\n";
$return = 1;
}
====
in case exec failed,
die "can't exec $p{Sendmail}: $!\n";
has two problems:
1) it will call END{} / DESTROY, when people don't expect (say, they'll have to add InactiveDestroy to DBI etc)
2) if executed in eval {} execution will continue in two separate processes.