Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp717523imm; Thu, 13 Sep 2018 06:46:03 -0700 (PDT) X-Google-Smtp-Source: ANB0VdapCcmYsuT2x1zRb4aRpSjeIUZDiifCc44jLs5uS4rAmqPgg+1mCrJlAxHudJ+fIfELkRZz X-Received: by 2002:a17:902:561:: with SMTP id 88-v6mr7368939plf.320.1536846363000; Thu, 13 Sep 2018 06:46:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536846362; cv=none; d=google.com; s=arc-20160816; b=NPFygs0dmNyDdZB2gSDMu5QPS2IimSnGOpWR897QYnWB9tLXvVjwMueFNmKsKCCCSv 483hnbrcsEjtLtaewD5iMGw6kYG/J3uBgjeHhWNXdr/muWRYXzmL09wHd1hw4FoErI2X 0cEXJazEDB0bZC42JQLpx6jokqzIsmFmeq77mbB8Wg7KMpvMsB48JSYtDdvKvRFAZuNh aC2+BNMeCLezl6043J+voidTjIb8Wa3aV5dJ3z3a9+Brsq55v8wdb6vgD0jbNOnHFzG5 zBjeN2BO58A3US+LPk4YlwkUiNKN9yeOwvF2BGwa+o+m1aKPTCbz7knjnrqp1DGkvPhE 2a/w== 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=GaUEmj4cQLnkWmUWPfZrParTz1rb2R3FtBRvSTe6xWA=; b=wGneapqZxVcNpBSbS+KVXkJmqGJm4HKjh8krDcRBuX8CwOUJEefPE1Q6E/3OwMVQx2 ukVXgm+4DF+mVPC+uYGVi1UiZJCkEAyK7gO1p31aWeRScioYNQApm18Vt9Y1WuyESKFO ss0btKNaf6sKPfszfdGx30hJN7URYMTw7no+jVXgmkgYaSXBNbiGn/Vhxv13wH0sH4fx 69LfMMTcMrOOwQhYkKzkpe/CiGb2MZirb9AN3cXOwFE5txjlzTVX0NI+psqUxhYcISa4 TyrxY//S+GknaQR65S4rUF8Tz10zOmIgr1DnyruA1cDHo+qvjZP+MGObMRc/GNv+bw0F bruQ== 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 34-v6si4250101plp.310.2018.09.13.06.45.48; Thu, 13 Sep 2018 06:46:02 -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 S1730181AbeIMSzQ (ORCPT + 99 others); Thu, 13 Sep 2018 14:55:16 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60742 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729570AbeIMSzP (ORCPT ); Thu, 13 Sep 2018 14:55:15 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 27BCBD1A; Thu, 13 Sep 2018 13:45:41 +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.14 069/115] selftests/powerpc: Kill child processes on SIGINT Date: Thu, 13 Sep 2018 15:31:29 +0200 Message-Id: <20180913131827.942975089@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131823.327472833@linuxfoundation.org> References: <20180913131823.327472833@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.14-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; }