From e437c44483028cc4a06bb99691a717196b5c037b Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 17 Mar 2010 18:02:46 +0100 Subject: [PATCH] [BUG] init: unconditionally catch SIGPIPE Apparently some systems define MSG_NOSIGNAL but do not necessarily check it (or maybe binaries are built somewhere and used on older versions). There were reports of very recent FreeBSD setups causing SIGPIPEs, while older ones catch the signal. Recent FreeBSD manpages indeed define MSG_NOSIGNAL. So let's now unconditionnaly catch the signal. It's useless not to do it for the rare cases where it's not needed (linux 2.4 and below). --- src/haproxy.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/haproxy.c b/src/haproxy.c index eb35b879f..a2843da1c 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -995,12 +995,11 @@ int main(int argc, char **argv) signal_register(SIGTERM, sig_term); #endif - /* on very high loads, a sigpipe sometimes happen just between the - * getsockopt() which tells "it's OK to write", and the following write :-( + /* Always catch SIGPIPE even on platforms which define MSG_NOSIGNAL. + * Some recent FreeBSD setups report broken pipes, and MSG_NOSIGNAL + * was defined there, so let's stay on the safe side. */ -#if !MSG_NOSIGNAL || defined(CONFIG_HAP_LINUX_SPLICE) signal(SIGPIPE, SIG_IGN); -#endif /* We will loop at most 100 times with 10 ms delay each time. * That's at most 1 second. We only send a signal to old pids