* [lttng-dev] [PATCH lttng-tools] Fix: ignore SIGPIPE
@ 2016-10-06 16:57 Mathieu Desnoyers
2016-10-07 21:19 ` Jérémie Galarneau
0 siblings, 1 reply; 2+ messages in thread
From: Mathieu Desnoyers @ 2016-10-06 16:57 UTC (permalink / raw)
Issuing fprintf() to stderr (thus write() 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_IGN in relayd, sessiond, and consumerd.
This was affecting sessiond and relayd. The consumerd did not print
anything to stderr.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
---
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(-)
diff --git a/src/bin/lttng-consumerd/lttng-consumerd.c b/src/bin/lttng-consumerd/lttng-consumerd.c
index 1636b9c..1373a74 100644
--- a/src/bin/lttng-consumerd/lttng-consumerd.c
+++ b/src/bin/lttng-consumerd/lttng-consumerd.c
@@ -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;
diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c
index e8f3087..ea46ec7 100644
--- a/src/bin/lttng-relayd/main.c
+++ b/src/bin/lttng-relayd/main.c
@@ -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;
}
diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c
index 1964fe0..a2afb8f 100644
--- a/src/bin/lttng-sessiond/main.c
+++ b/src/bin/lttng-sessiond/main.c
@@ -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
^ permalink raw reply [flat|nested] 2+ messages in thread
* [lttng-dev] [PATCH lttng-tools] Fix: ignore SIGPIPE
2016-10-06 16:57 [lttng-dev] [PATCH lttng-tools] Fix: ignore SIGPIPE Mathieu Desnoyers
@ 2016-10-07 21:19 ` Jérémie Galarneau
0 siblings, 0 replies; 2+ messages in thread
From: Jérémie Galarneau @ 2016-10-07 21:19 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 4977 bytes --]
Merged, thanks!
Jérémie
On 6 October 2016 at 12:57, Mathieu Desnoyers
<mathieu.desnoyers at efficios.com> wrote:
> Issuing fprintf() to stderr (thus write() 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_IGN in relayd, sessiond, and consumerd.
>
> This was affecting sessiond and relayd. The consumerd did not print
> anything to stderr.
>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> ---
> 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(-)
>
> diff --git a/src/bin/lttng-consumerd/lttng-consumerd.c b/src/bin/lttng-consumerd/lttng-consumerd.c
> index 1636b9c..1373a74 100644
> --- a/src/bin/lttng-consumerd/lttng-consumerd.c
> +++ b/src/bin/lttng-consumerd/lttng-consumerd.c
> @@ -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;
> diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c
> index e8f3087..ea46ec7 100644
> --- a/src/bin/lttng-relayd/main.c
> +++ b/src/bin/lttng-relayd/main.c
> @@ -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;
> }
> diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c
> index 1964fe0..a2afb8f 100644
> --- a/src/bin/lttng-sessiond/main.c
> +++ b/src/bin/lttng-sessiond/main.c
> @@ -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
>
--
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-10-07 21:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-06 16:57 [lttng-dev] [PATCH lttng-tools] Fix: ignore SIGPIPE Mathieu Desnoyers
2016-10-07 21:19 ` Jérémie Galarneau
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox