From 6ce8434dcf6ff95db7bc75a97fd1144e54206dfe Mon Sep 17 00:00:00 2001 From: David Levine Date: Thu, 3 Jan 2013 22:33:42 -0600 Subject: [PATCH] Block SIGPIPE before killing the child in sm_end(). This replaces the discard() calls that were removed in commit 4548a3ecc4248a1d4. --- mts/smtp/smtp.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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; -- 2.56.0