From patchwork Thu Dec 8 03:36:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 130088 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0B9E21007DA for ; Thu, 8 Dec 2011 14:37:15 +1100 (EST) Received: from localhost ([::1]:36687 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYUnH-0000Q3-PP for incoming@patchwork.ozlabs.org; Wed, 07 Dec 2011 22:37:11 -0500 Received: from eggs.gnu.org ([140.186.70.92]:45006) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYUnA-0000Pu-3N for qemu-devel@nongnu.org; Wed, 07 Dec 2011 22:37:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RYUn9-00059s-3P for qemu-devel@nongnu.org; Wed, 07 Dec 2011 22:37:04 -0500 Received: from mout.perfora.net ([74.208.4.195]:57461) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYUn8-00059b-ST for qemu-devel@nongnu.org; Wed, 07 Dec 2011 22:37:03 -0500 Received: from illuin.austin.ibm.com ([32.97.110.65]) by mrelay.perfora.net (node=mrus0) with ESMTP (Nemesis) id 0MMChx-1RgT0O1UFB-008280; Wed, 07 Dec 2011 22:36:53 -0500 From: Michael Roth To: qemu-devel@nongnu.org Date: Wed, 7 Dec 2011 21:36:40 -0600 Message-Id: <1323315400-25585-1-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.4.1 X-Provags-ID: V02:K0:Leag9kyCKpbkdrTfW1178ZBJshEO/6cnPBOgqgaIpwG oqd4fNB4hKOgw2ilcAMehx1eePDzdWJ/mRCO4yUCJeBvqHjkeS F639a7koUOt5mGxnen7BCo8+3LADQfeXW7wFCwWa5q4z2MIJ/O GRESkRktgVTT0L8YXmG60kGGkvtojq2tbmvMBmTA0MD+Q+lyso yjGuQ1eXgpwkg37mqAxqaGUqrIVWX5a0/R0BzXkKyy0vheWOHO hAz9nBIkltEeF2CkyC3DxNv6NT/ndRgOp9mkxTeF2slVwIWWy0 6SGIbA2JLmmZFrXcTJ1b1+nOSjtqY+87t/1OgbH8V2RmJBC4rZ 588ukh70h1L7BX/bKakyLKpfXnT1vXtbimMb4olsb5mQ6wH37b lzIeMSRXHqkMnz815r/SAzaAWkKyVg/E+0= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.208.4.195 Cc: jan.kiszka@siemens.com, mdroth@linux.vnet.ibm.com, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH] network scripts: don't block SIGCHLD before forking X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 | 5 ----- 1 files changed, 0 insertions(+), 5 deletions(-) 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;