From 4ff579c92b1358ba3fc995ad45a351ddda72c201 Mon Sep 17 00:00:00 2001 From: "John (J5) Palmieri" Date: Wed, 8 Nov 2006 23:10:48 +0000 Subject: * tools/dbus-monitor.c: Handle sigint so we flush stdout (Patch from Olli Salli ) --- tools/dbus-monitor.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/dbus-monitor.c b/tools/dbus-monitor.c index b86b85ad..77770445 100644 --- a/tools/dbus-monitor.c +++ b/tools/dbus-monitor.c @@ -26,6 +26,8 @@ #include #include +#include + #include "dbus-print-message.h" static DBusHandlerResult @@ -163,6 +165,14 @@ usage (char *name, int ecode) exit (ecode); } +dbus_bool_t sigint_received = FALSE; + +static void +sigint_handler (int signum) +{ + sigint_received = TRUE; +} + int main (int argc, char *argv[]) { @@ -254,7 +264,11 @@ main (int argc, char *argv[]) fprintf (stderr, "Couldn't add filter!\n"); exit (1); } - while (dbus_connection_read_write_dispatch(connection, -1)) + + /* we handle SIGINT so exit() is reached and flushes stdout */ + signal (SIGINT, sigint_handler); + while (dbus_connection_read_write_dispatch(connection, -1) + && !sigint_received) ; exit (0); lose: -- cgit