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-devel

[Xen-devel] [PATCH] SIGTERM and SIGINT handler to flush xentop -b output

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] SIGTERM and SIGINT handler to flush xentop -b outputs
From: INAKOSHI Hiroya <inakoshi.hiroya@xxxxxxxxxxxxxx>
Date: Tue, 02 Oct 2007 10:22:16 +0900
Delivery-date: Mon, 01 Oct 2007 18:23:09 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.6 (Windows/20070728)
# HG changeset patch
# User inakoshi.hiroya@xxxxxxxxxxxxxx
# Date 1191287395 -28800
# Node ID 5543e74774a826b1781893982ed5052312b820fc
# Parent  83239b2890723e0c06bad507bb273a970784b18e
Flush stdout when xentop -b gets SIGINT and SIGTERM.
It is useful when you stop xentop -b by keyboard interrupt or by other
programs such as killall from a batch script.
You would have missed the bottom part of xentop outputs without this patch.

Signed-off-by: INAKOSHI Hiroya <inakoshi.hiroya@xxxxxxxxxxxxxx>

diff -r 83239b289072 -r 5543e74774a8 tools/xenstat/xentop/xentop.c
--- a/tools/xenstat/xentop/xentop.c     Thu Sep 27 16:29:43 2007 -0600
+++ b/tools/xenstat/xentop/xentop.c     Tue Oct 02 09:09:55 2007 +0800
@@ -31,6 +31,7 @@
 #if defined(__linux__)
 #include <linux/kdev_t.h>
 #endif
+#include <signal.h>

 #include <xenstat.h>

@@ -1011,6 +1012,13 @@ static void top(void)
        free(domains);
 }

+
+void a_sig_handler(int n)
+{
+       fflush(stdout);
+       exit(0);
+}
+
 int main(int argc, char **argv)
 {
        int opt, optind = 0;
@@ -1102,6 +1110,8 @@ int main(int argc, char **argv)
                        ch = getch();
                } while (handle_key(ch));
        } else {
+                       signal(SIGTERM, a_sig_handler);
+                       signal(SIGINT, a_sig_handler);
                        do {
                                gettimeofday(&curtime, NULL);
                                top();


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

<Prev in Thread] Current Thread [Next in Thread>