From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:56007) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYUyV-0002QH-IE for qemu-devel@nongnu.org; Wed, 07 Dec 2011 22:48:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RYUyU-0006ZC-Ny for qemu-devel@nongnu.org; Wed, 07 Dec 2011 22:48:47 -0500 Received: from mout.perfora.net ([74.208.4.194]:49947) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYUyU-0006Z6-IC for qemu-devel@nongnu.org; Wed, 07 Dec 2011 22:48:46 -0500 From: Michael Roth Date: Wed, 7 Dec 2011 21:48:07 -0600 Message-Id: <1323316087-1070-1-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1323315400-25585-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1323315400-25585-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH v3] network scripts: don't block SIGCHLD before forking List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: jan.kiszka@siemens.com, mdroth@linux.vnet.ibm.com, pbonzini@redhat.com 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 handler: 7c3370d4fe3fa6cda8655f109e4659afc8ca4269 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: 4d54ec7898bd951007cb6122d5315584bd41d0c4 As a result, we can now avoid blocking SIGCHLD in launch_script(), so drop that behavior. Signed-off-by: Michael Roth --- net/tap.c | 6 ------ 1 files changed, 0 insertions(+), 6 deletions(-) diff --git a/net/tap.c b/net/tap.c index 1f26dc9..6c27a94 100644 --- a/net/tap.c +++ b/net/tap.c @@ -346,15 +346,10 @@ static TAPState *net_tap_fd_init(VLANState *vlan, static int launch_script(const char *setup_script, const char *ifname, int fd) { - sigset_t oldmask, mask; int pid, status; 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 +373,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; -- 1.7.4.1