Skip to contentSkip to conversation

iohandler.c: Properly initialize sigaction struct

PATCH Applied Peter Maydell 2 participants 2 messages May 16, 2014 – May 17, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iohandler.c: Properly initialize sigaction struct

The code in qemu_init_child_watch() wasn't clearing the 'struct sigaction' before passing it to sigaction(); this meant that we would block a random set of signals while executing the SIGCHLD handler. Initialize properly by using memset() on the struct, as we do in similar cases elsewhere.

---
Pretty harmless, but spotted by coverity.

 iohandler.c | 1 +
 1 file changed, 1 insertion(+)
iohandler.c +1 -0
index ae2ef8f..cca614f 100644
@@ -191,6 +191,7 @@ static void qemu_init_child_watch(void)
     struct sigaction act;
     sigchld_bh = qemu_bh_new(sigchld_bh_handler, NULL);
 
+    memset(&act, 0, sizeof(act));
     act.sa_handler = sigchld_handler;
     act.sa_flags = SA_NOCLDSTOP;
     sigaction(SIGCHLD, &act, NULL);
Signature · 1 line
1.9.2
#1 lore raw
Quoted 5 lines · Peter Maydell

The code in qemu_init_child_watch() wasn't clearing the 'struct sigaction' before passing it to sigaction(); this meant that we would block a random set of signals while executing the SIGCHLD handler. Initialize properly by using memset() on the struct, as we do in similar cases elsewhere

Applied to -trivial, thank you!

/mjt