Subject: | Documentation should mention $SIG{CHLD} handler |
Hey,
I tried using Email::Simple with the following code, as suggested in the
docs:
use Email::Sender::Simple qw(sendmail);
use Email::Simple;
use Email::Simple::Creator;
my $email = Email::Simple->create(
header => [
To => 'ms <michael@bar.net>',
From => 'noreply <noreply@localhost>',
Subject => qq|Share "$name_human" created|,
],
body => 'Testmail',
);
sendmail($email);
However, this would fail (every time) when calling sendmail, saying
"error when closing pipe to sendmail: No child processes" (line 79 of
Email/Sender/Transport/Sendmail.pm).
This is caused by Perl waiting on the pipe when calling 'close', and
according to wait(2), an errno of ECHILD can occur when SIGCHLD is
ignored (which seems to be the default, at least in a Dancer
application).
The problem goes away when setting $SIG{CHLD} = sub { wait }; before
calling sendmail(). So, this should either be documented if it’s
intended or you should handle ECHILD upon close $pipe;. Please don’t
fiddle with the signal handlers itself, that is most often an annoying
source of problems for the calling code :).
Best regards,
Michael