]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
* tools/dbus-monitor.c: Handle sigint so we flush stdout
authorJohn (J5) Palmieri <johnp@redhat.com>
Wed, 8 Nov 2006 23:10:48 +0000 (23:10 +0000)
committerJohn (J5) Palmieri <johnp@redhat.com>
Wed, 8 Nov 2006 23:10:48 +0000 (23:10 +0000)
  (Patch from Olli Salli <olli dot salli at collabora dot co dot uk>)

ChangeLog
tools/dbus-monitor.c

index a189aa398853905027eb37222182616d10cf3d1a..2576dcad818a172370f6c27bde32781034a3b032 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+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
index b86b85ad4b59410d49f81a718627f0a909a2445d..77770445fdd9a01c920f5e1c4009a6719e861830 100644 (file)
@@ -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: