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

Re: [Xen-devel] [PATCH] SIGTERM and SIGINT handler to flush xentop -b ou

To: INAKOSHI Hiroya <inakoshi.hiroya@xxxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] SIGTERM and SIGINT handler to flush xentop -b outputs
From: John Levon <levon@xxxxxxxxxxxxxxxxx>
Date: Tue, 2 Oct 2007 02:29:49 +0100
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Mon, 01 Oct 2007 18:30:52 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <47019D48.5070600@xxxxxxxxxxxxxx>
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>
References: <47019D48.5070600@xxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.9i
On Tue, Oct 02, 2007 at 10:22:16AM +0900, INAKOSHI Hiroya wrote:

> +void a_sig_handler(int n)
> +{
> +     fflush(stdout);
> +     exit(0);
> +}

Neither exit() nor fflush() are guaranteed signal safe:

http://opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html#tag_02_04_03

so can't be used in signal handlers.

>       } else {
> +                     signal(SIGTERM, a_sig_handler);
> +                     signal(SIGINT, a_sig_handler);

There's never a reason to use signal() these days, even if you made the
handler use _exit()

regards
john

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

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