[v2] network scripts: don't block SIGCHLD before forking

Message ID 1323315824-32510-1-git-send-email-mdroth@linux.vnet.ibm.com
State New
Headers show

Commit Message

Michael Roth Dec. 8, 2011, 3:43 a.m.
This patch fixes a bug where child processes of launch_script() can
misbehave due to SIGCHLD being blocked. In the case of `sudo`, this
causes a permanent hang.

Previously a SIGCHLD handler was added to reap fork_exec()'d zombie
processes by calling waitpid(-1, ...). This required other
fork()/waitpid() callers to temporarilly block SIGCHILD to avoid
having the final wait status being intercepted by the SIGCHLD


Since then, the qemu_add_child_watch() interface was added to allow
registration of such processes and reap only from that specific set
of PIDs:


As a result, we can now avoid blocking SIGCHLD in launch_script(), so
drop that behavior.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
 net/tap.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)


Michael Roth Dec. 8, 2011, 3:50 a.m. | #1
Bah, missed a 'git add', will resend. Sorry for the noise.


diff --git a/net/tap.c b/net/tap.c
index 1f26dc9..2cf79e1 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -351,10 +351,6 @@  static int launch_script(const char *setup_script, const char *ifname, int fd)
     char *args[3];
     char **parg;
-    sigemptyset(&mask);
-    sigaddset(&mask, SIGCHLD);
-    sigprocmask(SIG_BLOCK, &mask, &oldmask);
     /* try to launch network script */
     pid = fork();
     if (pid == 0) {
@@ -378,7 +374,6 @@  static int launch_script(const char *setup_script, const char *ifname, int fd)
         while (waitpid(pid, &status, 0) != pid) {
             /* loop */
-        sigprocmask(SIG_SETMASK, &oldmask, NULL);
         if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
             return 0;