Fix: ignore SIGPIPE
A message that is not in the archive (sent off-list or not yet received): [email protected]
Jérémie Galarneau
AppliedMerged, thanks!
Jérémie
Quoted 142 lines · Mathieu Desnoyers
Issuing
fprintf()to stderr (thuswrite()to the standard error file descriptor) within the SIGPIPE signal handler is bad: it can trigger SIGPIPE repeatedly if the listening end has closed its end of the pipe.Set the SIGPIPE action to
SIG_IGNin relayd, sessiond, and consumerd.This was affecting sessiond and relayd. The consumerd did not print anything to stderr.
Signed-off-by Mathieu Desnoyers <[email protected]>--- src/bin/lttng-consumerd/lttng-consumerd.c | 12 +++--------- src/bin/lttng-relayd/main.c | 11 +++++------ src/bin/lttng-sessiond/main.c | 11 +++++------ 3 files changed, 13 insertions(+), 21 deletions(-)src/bin/lttng-consumerd/lttng-consumerd.c +3
-9@@ -99,14 +99,6 @@ static void sighandler(int sig)return ; } -/* -* Ignore SIGPIPE because it should not stop the consumer whenever a -* SIGPIPE is caught through a FD operation. -*/ -if (sig ==SIGPIPE ) { -return ; - } -if (ctx) {lttng_consumer_should_exit (ctx); }@@ -127,9 +119,10 @@ static int set_signal_handler(void)return ret; } - sa.sa_handler = sighandler; sa.sa_mask = sigset; sa.sa_flags =0 ; + + sa.sa_handler = sighandler;if ((ret =sigaction (SIGTERM , &sa,NULL )) <0 ) {PERROR ("sigaction" );return ret;@@ -140,6 +133,7 @@ static int set_signal_handler(void)return ret; } + sa.sa_handler =SIG_IGN ;if ((ret =sigaction (SIGPIPE , &sa,NULL )) <0 ) {PERROR ("sigaction" );return ret;src/bin/lttng-relayd/main.c +5
-6@@ -582,9 +582,6 @@ int lttng_relay_stop_threads(void)static void sighandler (int sig) {switch (sig) { -case SIGPIPE : -DBG ("SIGPIPE caught" ); -return ;case SIGINT :DBG ("SIGINT caught" );if (lttng_relay_stop_threads ()) {@@ -620,9 +617,10 @@ static int set_signal_handler(void)return ret; } - sa.sa_handler = sighandler; sa.sa_mask = sigset; sa.sa_flags =0 ; + + sa.sa_handler = sighandler;if ((ret =sigaction (SIGTERM , &sa,NULL )) <0 ) {PERROR ("sigaction" );return ret;@@ -633,12 +631,13 @@ static int set_signal_handler(void)return ret; } -if ((ret =sigaction (SIGPIPE , &sa,NULL )) <0 ) { +if ((ret =sigaction (SIGUSR1 , &sa,NULL )) <0 ) {PERROR ("sigaction" );return ret; } -if ((ret =sigaction (SIGUSR1 , &sa,NULL )) <0 ) { + sa.sa_handler =SIG_IGN ; +if ((ret =sigaction (SIGPIPE , &sa,NULL )) <0 ) {PERROR ("sigaction" );return ret; }src/bin/lttng-sessiond/main.c +5
-7@@ -5370,9 +5370,6 @@ error:static void sighandler (int sig) {switch (sig) { -case SIGPIPE : -DBG ("SIGPIPE caught" ); -return ;case SIGINT :DBG ("SIGINT caught" );stop_threads ();@@ -5404,9 +5401,10 @@ static int set_signal_handler(void)return ret; } - sa.sa_handler = sighandler; sa.sa_mask = sigset; sa.sa_flags =0 ; + + sa.sa_handler = sighandler;if ((ret =sigaction (SIGTERM , &sa,NULL )) <0 ) {PERROR ("sigaction" );return ret;@@ -5417,12 +5415,13 @@ static int set_signal_handler(void)return ret; } -if ((ret =sigaction (SIGPIPE , &sa,NULL )) <0 ) { +if ((ret =sigaction (SIGUSR1 , &sa,NULL )) <0 ) {PERROR ("sigaction" );return ret; } -if ((ret =sigaction (SIGUSR1 , &sa,NULL )) <0 ) { + sa.sa_handler =SIG_IGN ; +if ((ret =sigaction (SIGPIPE , &sa,NULL )) <0 ) {PERROR ("sigaction" );return ret; } --2.1.4
Signature · 7 lines
Jérémie Galarneau EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev