Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp736997imm; Thu, 13 Sep 2018 07:03:10 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaKYscuaPHKTZWEXOOfwhRQ1qdR/VImNCDq95biB1Ukf9qj1X+3zJQo5sB2pV10qvB4DeM+ X-Received: by 2002:a63:549:: with SMTP id 70-v6mr7548331pgf.385.1536847390300; Thu, 13 Sep 2018 07:03:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536847390; cv=none; d=google.com; s=arc-20160816; b=C1MIBwudo4V//X33je++7Vexc1abygnXiWbQzlum2DPAWkbZSKL7xjengMHYzTpIZo sk1AmXflyTNfchvPZpJ5XQyV8+dWXb/Wsgux1tl1diqug4xTOoXcs+4V5qGzs5pcXwtB IxQJRFee6uJt3uveSPWRmUn2u+R/kONHOsE9qXaBtT1vugIp6g7I2op3I+t9PYStcSla WY4y5G1c7cc65zoNOYI3dliuWb3ZcoNMbDcMqa8Siu/NKy2V2uG+adBUyIIoGl1W5dK4 OO20gTP+qNjN0tXROhccA5mJZdc620Rk9WvG5xaMyCOgxQKHCv9N0a0ON7H96ou3LOY9 Q0Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=I1GAe3KrWfkOOCa3kKFwFzhdyP3ImWk5FMXXH8NUkmk=; b=pI7/7I6+V+THUPJ3kmRsfmlqdXlxBEFbSBFrBvghqO6vHnKJPy6YE7j1QsibDxUd8i Y4PhJMRPq+UiIDxCGRnuprInsxzjv+8Vq7uA+HvtuY6jridJux8ISj2E7SS8MHRuxUVz P/NvOhAXtalSqCSMCSK/Tm6L/qdBVKF4XjTpd6Y3m281t45vbTkD3vs8WQ+dupfQHpDM 6IxiP5Ke2gyjZ3/yXh6yaNrtHXTvNHdE+n457k3rY16q9m+m2mukIy8hh3ULroM80NwV EqdMa8r+mWhp6xbh3TN6JeM6B74n9KQbHZynENappYWkoKoyfX9yihux6haNVXnKN6C5 XQFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v4-v6si3933510pgn.110.2018.09.13.07.02.53; Thu, 13 Sep 2018 07:03:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731641AbeIMTL5 (ORCPT + 99 others); Thu, 13 Sep 2018 15:11:57 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35198 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731249AbeIMTL4 (ORCPT ); Thu, 13 Sep 2018 15:11:56 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 11B46D0E; Thu, 13 Sep 2018 14:02:17 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Breno Leitao , Gustavo Romero , Michael Ellerman , Sasha Levin Subject: [PATCH 4.18 116/197] selftests/powerpc: Kill child processes on SIGINT Date: Thu, 13 Sep 2018 15:31:05 +0200 Message-Id: <20180913131846.190275079@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131841.568116777@linuxfoundation.org> References: <20180913131841.568116777@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Breno Leitao [ Upstream commit 7c27a26e1ed5a7dd709aa19685d2c98f64e1cf0c ] There are some powerpc selftests, as tm/tm-unavailable, that run for a long period (>120 seconds), and if it is interrupted, as pressing CRTL-C (SIGINT), the foreground process (harness) dies but the child process and threads continue to execute (with PPID = 1 now) in background. In this case, you'd think the whole test exited, but there are remaining threads and processes being executed in background. Sometimes these zombies processes are doing annoying things, as consuming the whole CPU or dumping things to STDOUT. This patch fixes this problem by attaching an empty signal handler to SIGINT in the harness process. This handler will interrupt (EINTR) the parent process waitpid() call, letting the code to follow through the normal flow, which will kill all the processes in the child process group. This patch also fixes a typo. Signed-off-by: Breno Leitao Signed-off-by: Gustavo Romero Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/testing/selftests/powerpc/harness.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) --- a/tools/testing/selftests/powerpc/harness.c +++ b/tools/testing/selftests/powerpc/harness.c @@ -85,13 +85,13 @@ wait: return status; } -static void alarm_handler(int signum) +static void sig_handler(int signum) { - /* Jut wake us up from waitpid */ + /* Just wake us up from waitpid */ } -static struct sigaction alarm_action = { - .sa_handler = alarm_handler, +static struct sigaction sig_action = { + .sa_handler = sig_handler, }; void test_harness_set_timeout(uint64_t time) @@ -106,8 +106,14 @@ int test_harness(int (test_function)(voi test_start(name); test_set_git_version(GIT_VERSION); - if (sigaction(SIGALRM, &alarm_action, NULL)) { - perror("sigaction"); + if (sigaction(SIGINT, &sig_action, NULL)) { + perror("sigaction (sigint)"); + test_error(name); + return 1; + } + + if (sigaction(SIGALRM, &sig_action, NULL)) { + perror("sigaction (sigalrm)"); test_error(name); return 1; }