From: David Levine Date: Fri, 4 Jan 2013 04:33:42 +0000 (-0600) Subject: Block SIGPIPE before killing the child in sm_end(). This replaces X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/6ce8434dcf6ff95db7bc75a97fd1144e54206dfe?hp=-c Block SIGPIPE before killing the child in sm_end(). This replaces the discard() calls that were removed in commit 4548a3ecc4248a1d4. --- 6ce8434dcf6ff95db7bc75a97fd1144e54206dfe diff --git a/mts/smtp/smtp.c b/mts/smtp/smtp.c index 4b2e30a6..6fd178bc 100755 --- a/mts/smtp/smtp.c +++ b/mts/smtp/smtp.c @@ -798,7 +798,19 @@ sm_end (int type) if (sm_mts == MTS_SMTP) smtalk (SM_QUIT, "QUIT"); else { + /* The SIGPIPE block replaces old calls to discard (). + We're not sure what the discard () calls were for, + maybe to prevent deadlock on old systems. In any + case, blocking SIGPIPE should be harmless. + Because the file handles are closed below, leave it + blocked. */ + sigset_t set, oset; + sigemptyset (&set); + sigaddset (&set, SIGPIPE); + sigprocmask (SIG_BLOCK, &set, &oset); + kill (sm_child, SIGKILL); + sm_child = NOTOK; } if (type == NOTOK) { sm_reply.code = sm_note.code; @@ -838,9 +850,11 @@ sm_end (int type) if (sasl_inbuffer) free(sasl_inbuffer); #endif /* CYRUS_SASL */ - } else { + } else if (sm_child != NOTOK) { status = pidwait (sm_child, OK); sm_child = NOTOK; + } else { + status = OK; } sm_rfp = sm_wfp = NULL;