linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ] core: Ignore SIGPIPE
@ 2018-11-16 19:14 Gal Ben-Haim
  2018-11-16 19:30 ` Luiz Augusto von Dentz
  2018-11-16 20:01 ` Marcel Holtmann
  0 siblings, 2 replies; 8+ messages in thread
From: Gal Ben-Haim @ 2018-11-16 19:14 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Gal Ben-Haim

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.

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

diff --git a/src/main.c b/src/main.c
index 4716f5388..c62886593 100644
--- a/src/main.c
+++ b/src/main.c
@@ -691,7 +691,7 @@ int main(int argc, char *argv[])
 	uint16_t sdp_mtu = 0;
 	uint32_t sdp_flags = 0;
 	int gdbus_flags = 0;
-	guint signal, watchdog;
+	guint signal_source, watchdog;
 	const char *watchdog_usec;
 
 	init_defaults();
@@ -721,7 +721,11 @@ int main(int argc, char *argv[])
 
 	event_loop = g_main_loop_new(NULL, FALSE);
 
-	signal = setup_signalfd();
+	signal_source = setup_signalfd();
+
+	/* Ignore SIGPIPE, a broken pipe error will be returned from write 
+	 * attempts to a pipe with no readers */
+	signal(SIGPIPE, SIG_IGN);
 
 	__btd_log_init(option_debug, option_detach);
 
@@ -809,7 +813,7 @@ int main(int argc, char *argv[])
 
 	sd_notify(0, "STATUS=Quitting");
 
-	g_source_remove(signal);
+	g_source_remove(signal_source);
 
 	plugin_cleanup();
 
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-11-17 15:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-16 19:14 [PATCH BlueZ] core: Ignore SIGPIPE Gal Ben-Haim
2018-11-16 19:30 ` Luiz Augusto von Dentz
2018-11-16 19:54   ` Gal Ben Haim
2018-11-16 20:01 ` Marcel Holtmann
2018-11-16 20:11   ` Gal Ben Haim
2018-11-16 23:45     ` Gal Ben Haim
2018-11-17  9:29       ` Luiz Augusto von Dentz
2018-11-17 15:04         ` Gal Ben Haim

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).