From patchwork Wed Jul 5 11:53:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= X-Patchwork-Id: 116093 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1820940vqx; Wed, 5 Jul 2023 05:12:21 -0700 (PDT) X-Google-Smtp-Source: APBJJlFvc+aCZ2lNcTWwRqITlW4ibjO42COzUyF1u89ft6a12C0hzmVdgmp0WB5oHEWcDwGTwRrA X-Received: by 2002:a05:6808:130d:b0:3a3:94f4:adca with SMTP id y13-20020a056808130d00b003a394f4adcamr14273518oiv.2.1688559141323; Wed, 05 Jul 2023 05:12:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688559141; cv=none; d=google.com; s=arc-20160816; b=E2LgIGNljuDdcB4EMwYLs6FfbuOO+z+YWNvYQ1NEUtqKwWDV0bAeuw4rL6ZQsA3DEy MbyxLkzgxt8oTYf44Kgngc/rgr8V60a+B4DsV2x5dNf0W3kuTXdCIYSU6vFZn+VN2O4z y4YPAabvI4aJtV9JaeQgEnt5aHfquD+WSIbfe/ZG7k7EEjVQqfQgWVR62C0u+BY6jFlo KVK2lR1nRIDOLS56Cv5hmlmpakqF1XWZDd7eIlPEZ283UZydDvENWKAhOqoWiE4k/zVV EDCRCwAZ0rc0SfyY/Ja2DJN82cM2OLUaUk9EPuP2iBERCFKiuEdWKAxc2Bg+Dg3wkEHm hI/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=vfR8/ZSX0/D6M8s9Gj9d1Mbb5rBuYKNTQrlLB2P7y0c=; fh=LKec7XLGyuSMOLrd351MqMEFrzGOiJ/AJCK7gwBCeZM=; b=RcaLLicWNYkH6Wlj7dUfaUxgE2jHdVi8GIB4Qierdl7ErcFI1oHQYg8s3qMJk7WDJL CJ+EI+GbCwh22ZtMFU1WPf2WbB/lqDMDdDSkNU6fAhJdATwvz/uy7vub8s23F3n4YMVp Ru9oXWqJACfS8cVqRRyH0CYokqhpCfb7aXJKj2fGnwVBs2o/npgJhyWnAdVrrpm8cXjT MbDP5H5d4PXoyOhNR+J2tYV+OqNIbEBm3HyJV8jkEhdCszoEhwCjkKKa0BoD3VhfXEwu iUwyNismAjESWM5gHx+OmrYONkUYRRtQhfkej1NnTyxpdpkrZXovwdOn3H1tm3rXWcGV +PJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gQbr81r4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x3-20020a634a03000000b0054fd77fe97asi22509417pga.267.2023.07.05.05.12.08; Wed, 05 Jul 2023 05:12:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gQbr81r4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231445AbjGELxp (ORCPT + 99 others); Wed, 5 Jul 2023 07:53:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230477AbjGELxo (ORCPT ); Wed, 5 Jul 2023 07:53:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B848A1; Wed, 5 Jul 2023 04:53:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 33CCD6150F; Wed, 5 Jul 2023 11:53:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94540C433C7; Wed, 5 Jul 2023 11:53:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688558002; bh=ieO2X/lBi2r10eqVd5hEK+hSNE8vmZv8+Pqsk4DwJpM=; h=From:To:Cc:Subject:Date:From; b=gQbr81r4/R+ddRIVgmE0eAMEoagIJLFIX/cjIvoNiy+BHkOfX9g/DqXPDJs5WgKQ5 mqEMTePBQEugZobzXpsEOWAUs4s0uMc/ZTvfK1DSt/K3UZ+dpetvaskhUjLhDVkh4h G7vElXTvtboFmjT/+dRKu392wcxUMv3FbCjL8rllPFjlRm5RCcB76a6LlkFEESn4bK lJ4C+BvPwEZQJtjURFUCZ84HNsCByMtWqHYWZU5FoJhLHJiCBh3oPVxNgFXF7MKYgs NgU4mhEy/5RPVUlBoElbtyXe7z+THStzPCNIJfIVMz7bNE2I8HA9Yfrze6rMdbxKOx 1Ubm8Txt+ci7g== From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: Shuah Khan , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Andrea Righi , Kees Cook , Mirsad Goran Todorovac , netdev@vger.kernel.org Subject: [PATCH] kselftest/runner.sh: Propagate SIGTERM to runner child Date: Wed, 5 Jul 2023 13:53:17 +0200 Message-Id: <20230705115317.753182-1-bjorn@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770582590171962469?= X-GMAIL-MSGID: =?utf-8?q?1770582590171962469?= From: Björn Töpel Timeouts in kselftest are done using the "timeout" command with the "--foreground" option. Without the "foreground" option, it is not possible for a user to cancel the runner using SIGINT, because the signal is not propagated to timeout which is running in a different process group. The "forground" options places the timeout in the same process group as its parent, but only sends the SIGTERM (on timeout) signal to the forked process. Unfortunately, this does not play nice with all kselftests, e.g. "net:fcnal-test.sh", where the child processes will linger because timeout does not send SIGTERM to the group. Some users have noted these hangs [1]. Fix this by nesting the timeout with an additional timeout without the foreground option. Link: https://lore.kernel.org/all/7650b2eb-0aee-a2b0-2e64-c9bc63210f67@alu.unizg.hr/ # [1] Fixes: 651e0d881461 ("kselftest/runner: allow to properly deliver signals to tests") Signed-off-by: Björn Töpel --- tools/testing/selftests/kselftest/runner.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) base-commit: d528014517f2b0531862c02865b9d4c908019dc4 diff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/selftests/kselftest/runner.sh index 1c952d1401d4..70e0a465e30d 100644 --- a/tools/testing/selftests/kselftest/runner.sh +++ b/tools/testing/selftests/kselftest/runner.sh @@ -36,7 +36,8 @@ tap_timeout() { # Make sure tests will time out if utility is available. if [ -x /usr/bin/timeout ] ; then - /usr/bin/timeout --foreground "$kselftest_timeout" $1 + /usr/bin/timeout --foreground "$kselftest_timeout" \ + /usr/bin/timeout "$kselftest_timeout" $1 else $1 fi