I have a C program that calls Postfix's sendmail front-end using execv()
(after calling fork()). I also have a waitpid() on the process, which
diligently checks the status value returned by sendmail. I tried to
sabotage an e-mail by inserting a sender that is un-RFC822, and there
were errors sent to the standard error, but the return status that
waitpid() received was 0. What's the proper way to be checking for
errors generated by sendmail? This could lead to lost mail, since silent
errors will allow for mail to be deleted when it is presumed sent.
Also, I don't know if this is related to sendmail, exactly, but I
also want my program to capture the standard error from sendmail. I do
this by making the write end of a pipe descriptor 2 by calling close()
and dup(). Indeed, if I write to descriptor 2, in the child, before the
execv() call, this *is* sent through the pipe. But when sendmail is
called, the text is sent not to the pipe, but the original standard
error descriptor, which should be impossible, because that descriptor is
*closed* in the child. See
http://cboard.cprogramming.com/linux-programming/121461-capturing-stderr-execv-ed-process.html
for the exhaustive explanation.