WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] xentop: Flush batch output on SIGTERM or

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xentop: Flush batch output on SIGTERM or SIGINT.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 02 Oct 2007 17:40:21 -0700
Delivery-date: Tue, 02 Oct 2007 18:26:57 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir@xxxxxxxxxxxxx>
# Date 1191327565 -3600
# Node ID 818cc26e3926614d0e9c2431c746a56bb645337d
# Parent  d9039e8103e4901f4b509fbeeba011d73885bfba
xentop: Flush batch output on SIGTERM or SIGINT.
Signed-off-by: INAKOSHI Hiroya <inakoshi.hiroya@xxxxxxxxxxxxxx>
---
 tools/xenstat/xentop/xentop.c |   32 ++++++++++++++++++++++++--------
 1 files changed, 24 insertions(+), 8 deletions(-)

diff -r d9039e8103e4 -r 818cc26e3926 tools/xenstat/xentop/xentop.c
--- a/tools/xenstat/xentop/xentop.c     Tue Oct 02 10:53:14 2007 +0100
+++ b/tools/xenstat/xentop/xentop.c     Tue Oct 02 13:19:25 2007 +0100
@@ -28,6 +28,7 @@
 #include <sys/time.h>
 #include <time.h>
 #include <unistd.h>
+#include <signal.h>
 #if defined(__linux__)
 #include <linux/kdev_t.h>
 #endif
@@ -1011,6 +1012,13 @@ static void top(void)
        free(domains);
 }
 
+static int signal_exit;
+
+void signal_exit_handler(int sig)
+{
+       signal_exit = 1;
+}
+
 int main(int argc, char **argv)
 {
        int opt, optind = 0;
@@ -1102,14 +1110,22 @@ int main(int argc, char **argv)
                        ch = getch();
                } while (handle_key(ch));
        } else {
-                       do {
-                               gettimeofday(&curtime, NULL);
-                               top();
-                               oldtime = curtime;
-                               if ((!loop) && !(--iterations))
-                                       break;
-                               sleep(delay);
-                       } while (1);
+               struct sigaction sa = {
+                       .sa_handler = signal_exit_handler,
+                       .sa_flags = 0
+               };
+               sigemptyset(&sa.sa_mask);
+               sigaction(SIGINT, &sa, NULL);
+               sigaction(SIGTERM, &sa, NULL);
+
+               do {
+                       gettimeofday(&curtime, NULL);
+                       top();
+                       oldtime = curtime;
+                       if ((!loop) && !(--iterations))
+                               break;
+                       sleep(delay);
+               } while (!signal_exit);
        }
 
        /* Cleanup occurs in cleanup(), so no work to do here. */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xentop: Flush batch output on SIGTERM or SIGINT., Xen patchbot-unstable <=