From mboxrd@z Thu Jan 1 00:00:00 1970 From: INAKOSHI Hiroya Subject: Re: [PATCH] SIGTERM and SIGINT handler to flush xentop -b outputs Date: Tue, 02 Oct 2007 19:57:44 +0900 Message-ID: <47022428.1060607@jp.fujitsu.com> References: <47019D48.5070600@jp.fujitsu.com> <20071002012949.GB21202@totally.trollied.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20071002012949.GB21202@totally.trollied.org.uk> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: John Levon Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org John, thanks for your comment. I see your point. I will post another patch in a separate e-mail. It uses a signal handler in a safe manner. Regards, Hiroya John Levon wrote: > 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@lists.xensource.com > http://lists.xensource.com/xen-devel > >