All of lore.kernel.org
 help / color / mirror / Atom feed
From: INAKOSHI Hiroya <inakoshi.hiroya@jp.fujitsu.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] SIGTERM and SIGINT handler to flush xentop -b outputs
Date: Tue, 02 Oct 2007 10:22:16 +0900	[thread overview]
Message-ID: <47019D48.5070600@jp.fujitsu.com> (raw)

# HG changeset patch
# User inakoshi.hiroya@jp.fujitsu.com
# 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@jp.fujitsu.com>

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();

             reply	other threads:[~2007-10-02  1:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-02  1:22 INAKOSHI Hiroya [this message]
2007-10-02  1:29 ` [PATCH] SIGTERM and SIGINT handler to flush xentop -b outputs John Levon
2007-10-02 10:57   ` INAKOSHI Hiroya
  -- strict thread matches above, loose matches on Subject: below --
2007-10-02 11:10 INAKOSHI Hiroya

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47019D48.5070600@jp.fujitsu.com \
    --to=inakoshi.hiroya@jp.fujitsu.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.