summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn (J5) Palmieri <johnp@redhat.com>2006-11-08 23:10:48 +0000
committerJohn (J5) Palmieri <johnp@redhat.com>2006-11-08 23:10:48 +0000
commit4ff579c92b1358ba3fc995ad45a351ddda72c201 (patch)
treefba08d8c6a7d731d5b77e70a7086bf7a6bc2bb02
parentb6905b75b6ec77400b25fe340852626871649bd3 (diff)
* tools/dbus-monitor.c: Handle sigint so we flush stdout
(Patch from Olli Salli <olli dot salli at collabora dot co dot uk>)
-rw-r--r--ChangeLog6
-rw-r--r--tools/dbus-monitor.c16
2 files changed, 21 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index a189aa39..2576dcad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2006-11-08 John (J5) Palmieri <johnp@redhat.com>
+ * tools/dbus-monitor.c: Handle sigint so we flush stdout
+ (Patch from Olli Salli <olli dot salli at collabora dot co dot uk>)
+
+
+2006-11-08 John (J5) Palmieri <johnp@redhat.com>
+
* tools/dbus-monitor.1: update the manpage for dbus-monitor
(Patch from Olli Salli <olli dot salli at collabora dot co dot uk>)
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 <sys/time.h>
#include <time.h>
+#include <signal.h>
+
#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: