Skip to contentSkip to conversation

Fix signal handling when io-thread is disabled

PATCH Applied Alexandre Raymond 3 participants 4 messages Jun 14, 2011 – Jul 16, 2011

lore
Share & tools
lore
#0 lore raw

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

Changes since v1:
- take pthread_sigmask() out of the ifdef as it is now common to both parts.

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 |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
cpus.c +1 -1
index 4ab76f0..18a1522 100644
@@ -399,7 +399,6 @@ static int qemu_signal_init(void)
     sigaddset(&set, SIGALRM);
     sigaddset(&set, SIG_IPI);
     sigaddset(&set, SIGBUS);
-    pthread_sigmask(SIG_BLOCK, &set, NULL);
 #else
     sigemptyset(&set);
     sigaddset(&set, SIGBUS);
@@ -412,6 +411,7 @@ static int qemu_signal_init(void)
         sigaddset(&set, SIGALRM);
     }
 #endif
+    pthread_sigmask(SIG_BLOCK, &set, NULL);
 
     sigfd = qemu_signalfd(&set);
     if (sigfd == -1) {
Signature · 1 line
1.7.5
Acked-by on v2 1/1
#1 lore raw
Quoted 29 lines · Alexandre Raymond

Changes since v1:
- take pthread_sigmask() out of the ifdef as it is now common to both parts.

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 |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
cpus.c +0 -1
index 4ab76f0..18a1522 100644
@@ -399,7 +399,6 @@ static int qemu_signal_init(void)
     sigaddset(&set, SIGALRM);
     sigaddset(&set, SIG_IPI);
     sigaddset(&set, SIGBUS);
-    pthread_sigmask(SIG_BLOCK, &set, NULL);
 #else
     sigemptyset(&set);
     sigaddset(&set, SIGBUS);

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

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

Thanks,
Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#2 lore raw

ping?

Quoted 47 lines · Jan Kiszka
Quoted 29 lines · Alexandre Raymond

Changes since v1:
- take pthread_sigmask() out of the ifdef as it is now common to both parts.

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 |    2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
cpus.c +0 -1
index 4ab76f0..18a1522 100644
@@ -399,7 +399,6 @@ static int qemu_signal_init(void)
      sigaddset(&set, SIGALRM);
      sigaddset(&set, SIG_IPI);
      sigaddset(&set, SIGBUS);
-    pthread_sigmask(SIG_BLOCK, &set, NULL);
  #else
      sigemptyset(&set);
      sigaddset(&set, SIGBUS);

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

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

Thanks,
Jan

--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

Applied
#3 lore raw

Thanks, applied.

Quoted 52 lines · Alexandre Raymond

ping?

Quoted 47 lines · Jan Kiszka
Quoted 29 lines · Alexandre Raymond

Changes since v1:
- take pthread_sigmask() out of the ifdef as it is now common to both parts.

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 |    2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
cpus.c +0 -1
index 4ab76f0..18a1522 100644
@@ -399,7 +399,6 @@ static int qemu_signal_init(void)
      sigaddset(&set, SIGALRM);
      sigaddset(&set, SIG_IPI);
      sigaddset(&set, SIGBUS);
-    pthread_sigmask(SIG_BLOCK, &set, NULL);
  #else
      sigemptyset(&set);
      sigaddset(&set, SIGBUS);

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

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

Thanks,
Jan

--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux