[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



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@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel





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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.