From 63f7c1b3d137f60752c87e6b2dfc07436b3027f6 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 1 Nov 2013 16:33:57 +0800 Subject: [PATCH 2/2] capture.c: ignore SIGPIPE if message capture enabled Since we use popen(3) to pipe the captured package to stdin, it's necessary to ignore SIGPIPE to prevent us from crash if the pipe broken by any reason. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=60859 --- bus/capture.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bus/capture.c b/bus/capture.c index f15a7c3..4dc84fb 100644 --- a/bus/capture.c +++ b/bus/capture.c @@ -22,7 +22,9 @@ */ #include +#include #include "capture.h" +#include "dbus/dbus-sysdeps.h" #ifdef DBUS_ENABLE_CAPTURE @@ -71,6 +73,9 @@ bus_capture_maybe_start (BusCapture *self, if (command == NULL || *command == '\0') return; + /* ignore SIGPIPE so we don't crash if the capture pipe broken */ + _dbus_set_signal_handler (SIGPIPE, SIG_IGN); + /* For simplicity, we use stdio to perform blocking I/O. */ self->pcap = popen (command, "w"); -- 1.7.9.5