Skip to contentSkip to conversation

Fix signal handling when io-thread is disabled

PATCH Superseded Alexandre Raymond 2 participants 3 messages Jun 14, 2011

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix signal handling when io-thread is disabled

This fix effectively blocks, in the main thread, the signals handled by signalfd or the compatibility signal thread.

This way, such signals are received synchronously in the main thread through sigfd_handler() instead of triggering the signal handler directly, asynchronously.

---
 cpus.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
cpus.c +1 -0
index 4ab76f0..b6366b5 100644
@@ -411,6 +411,7 @@ static int qemu_signal_init(void)
         sigaddset(&set, SIGIO);
         sigaddset(&set, SIGALRM);
     }
+    pthread_sigmask(SIG_BLOCK, &set, NULL);
 #endif
 
     sigfd = qemu_signalfd(&set);
Signature · 1 line
1.7.5
#1 lore raw
Quoted 17 lines · Alexandre Raymond

This fix effectively blocks, in the main thread, the signals handled by signalfd or the compatibility signal thread.

This way, such signals are received synchronously in the main thread through sigfd_handler() instead of triggering the signal handler directly, asynchronously.

---
 cpus.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
cpus.c +0 -0
index 4ab76f0..b6366b5 100644

cpus.c static int qemu_signal_init(void) · line 417

Quoted 7 lines
cpus.c +1 -0
@@ -411,6 +411,7 @@ static int qemu_signal_init(void)
         sigaddset(&set, SIGIO);
         sigaddset(&set, SIGALRM);
     }
+    pthread_sigmask(SIG_BLOCK, &set, NULL);
 #endif
 
     sigfd = qemu_signalfd(&set);

Good catch. Probably remained unnoticed as most of us have signalfd support on their boxes so that the window for async delivery was rather small.

But please pull the now common pthread_sigmask out of the #ifdef.

Jan

#2 lore raw

Hi Jan,

Thanks for reviewing my patch.

Quoted 1 line

But please pull the now common pthread_sigmask out of the #ifdef.

Please see v2.

Alexandre