Re: [Qemu-devel] [PATCH RFC] main loop: fix some accesses made in sighandler context

2011-09-16 Thread Eric Blake
+++ b/cpus.c @@ -289,9 +289,16 @@ static void qemu_event_increment(void) /* EAGAIN is fine, a read must be pending. */ if (ret < 0 && errno != EAGAIN) { -fprintf(stderr, "qemu_event_increment: write() failed: %s\n", -strerror(errno)); -exit (1); +

Re: [Qemu-devel] [PATCH RFC] main loop: fix some accesses made in sighandler context

2011-09-16 Thread Markus Armbruster
Laszlo Ersek writes: > On 09/15/11 21:44, Peter Maydell wrote: >> On 15 September 2011 18:22, Laszlo Ersek wrote: >>> -int no_shutdown = 0; >>> +volatile int no_shutdown = 0; >> >> So why 'volatile' and not 'sig_atomic_t', then? > > The sigaction() spec says"volatile sig_atomic_t", so that woul

Re: [Qemu-devel] [PATCH RFC] main loop: fix some accesses made in sighandler context

2011-09-16 Thread Laszlo Ersek
On 09/15/11 21:16, Anthony Liguori wrote: On 09/15/2011 12:22 PM, Laszlo Ersek wrote: http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04_03_03 I don't think you can rely on snprintf being signal safe. I think you should just exit on failure. OpenBSD lists snp

Re: [Qemu-devel] [PATCH RFC] main loop: fix some accesses made in sighandler context

2011-09-16 Thread Laszlo Ersek
On 09/15/11 21:44, Peter Maydell wrote: On 15 September 2011 18:22, Laszlo Ersek wrote: -int no_shutdown = 0; +volatile int no_shutdown = 0; So why 'volatile' and not 'sig_atomic_t', then? The sigaction() spec says"volatile sig_atomic_t", so that would be ideal. My assumption was that "si

Re: [Qemu-devel] [PATCH RFC] main loop: fix some accesses made in sighandler context

2011-09-15 Thread Peter Maydell
On 15 September 2011 18:22, Laszlo Ersek wrote: > -int no_shutdown = 0; > +volatile int no_shutdown = 0; So why 'volatile' and not 'sig_atomic_t', then? thanks -- PMM

Re: [Qemu-devel] [PATCH RFC] main loop: fix some accesses made in sighandler context

2011-09-15 Thread Anthony Liguori
On 09/15/2011 12:22 PM, Laszlo Ersek wrote: Make variables volatile ("sig_atomic_t" should cover "int" and "pid_t"). Also replace calls to functions that are not required to be async-signal-safe [1]. (I haven't checked if any signal masks and/or previous suspension of the interrupted thread keep

[Qemu-devel] [PATCH RFC] main loop: fix some accesses made in sighandler context

2011-09-15 Thread Laszlo Ersek
Make variables volatile ("sig_atomic_t" should cover "int" and "pid_t"). Also replace calls to functions that are not required to be async-signal-safe [1]. (I haven't checked if any signal masks and/or previous suspension of the interrupted thread keep the current calls safe.) termsig_handler()