linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gal Ben-Haim <gbenhaim@augury.com>
To: linux-bluetooth@vger.kernel.org
Cc: Gal Ben-Haim <gbenhaim@augury.com>
Subject: [PATCH BlueZ] core: Catch SIGPIPE
Date: Sat, 17 Nov 2018 08:00:24 +0200	[thread overview]
Message-ID: <20181117060024.10390-1-gbenhaim@augury.com> (raw)

bluetoothd receives a SIGPIPE and terminates if writing to a pipe that
was acquired by AcquireNotify and there are no readers. it can be
reproduced by terminating the reader process without closing the reader
end of the pipe.

Catching SIGPIPE will cause the write call to return an EPIPE error
which will be logged as "io_send: Broken pipe".
---
 src/main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/main.c b/src/main.c
index 4716f5388..54cdb8d3f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -533,6 +533,8 @@ static gboolean signal_handler(GIOChannel *channel, GIOCondition cond,
 	case SIGUSR2:
 		__btd_toggle_debug();
 		break;
+	case SIGPIPE:
+		break;
 	}
 
 	return TRUE;
@@ -549,6 +551,7 @@ static guint setup_signalfd(void)
 	sigaddset(&mask, SIGINT);
 	sigaddset(&mask, SIGTERM);
 	sigaddset(&mask, SIGUSR2);
+	sigaddset(&mask, SIGPIPE);
 
 	if (sigprocmask(SIG_BLOCK, &mask, NULL) < 0) {
 		perror("Failed to set signal mask");
-- 
2.19.1


             reply	other threads:[~2018-11-17  6:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-17  6:00 Gal Ben-Haim [this message]
2018-11-17 20:41 ` [PATCH BlueZ] core: Catch SIGPIPE Gal Ben Haim
2018-11-17 20:47   ` Gal Ben Haim
2018-11-19  9:22     ` Luiz Augusto von Dentz
2018-11-19  9:47       ` Gal Ben Haim
2018-11-19 10:59         ` Luiz Augusto von Dentz
2018-11-19 13:27       ` Marcel Holtmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181117060024.10390-1-gbenhaim@augury.com \
    --to=gbenhaim@augury.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).