From patchwork Thu Nov 10 13:54:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Doucha X-Patchwork-Id: 1702153 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=qcQ7ii6V; dkim=fail reason="signature verification failed" header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=8oJ0vWfh; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4N7NdD1RN9z23lW for ; Fri, 11 Nov 2022 00:55:10 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 3879A3CD8B3 for ; Thu, 10 Nov 2022 14:55:01 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 7EDCA3CD619 for ; Thu, 10 Nov 2022 14:54:59 +0100 (CET) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id 0006C600468 for ; Thu, 10 Nov 2022 14:54:58 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 0B14422AA1 for ; Thu, 10 Nov 2022 13:54:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1668088498; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=mz9I9QWPxueFDhdE2r9nIV+h6CwFjNWwVoEXfsh73kA=; b=qcQ7ii6VUJZfq/8ghVHqsbwB0mrl9ZQxcengD5ugO+4e3ETQJ8ceeFvcjWGe1WYpAAxWrd jV56UKZ3JtXNZtZLS3zFvQeNSpJl6meXSqra4EKuJjFTor1onI/rnvwYElr1SpZF/45odE IU8my7NZJHt//+G/uIppHhbaZxyHeVo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1668088498; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=mz9I9QWPxueFDhdE2r9nIV+h6CwFjNWwVoEXfsh73kA=; b=8oJ0vWfhdEPH+R4u78iTTU12shti67aId4ROspYjt4LZkeXOvC0OfKzqSJ6igFubB1LUIu VOnEf5nFMx5g+qCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id EF7D91332F for ; Thu, 10 Nov 2022 13:54:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id E3CcObECbWOxDAAAMHmgww (envelope-from ) for ; Thu, 10 Nov 2022 13:54:57 +0000 From: Martin Doucha To: ltp@lists.linux.it Date: Thu, 10 Nov 2022 14:54:42 +0100 Message-Id: <20221110135442.14501-1-mdoucha@suse.cz> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH] Allow graceful subtest cleanup in shell tests X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" The new shell test timeout code sends SIGTERM to any subprocesses when the main script hits timeout. SIGTERM isn't handled by the LTP library which means that tools like netstress will be instantly killed without performing any cleanup. Handle SIGTERM like SIGINT in LTP library to allow graceful cleanup. Signed-off-by: Martin Doucha Reviewed-by: Petr Vorel --- Note: The current lack of graceful cleanup causes random failures in shell tests which run the same tool many times (e.g. netstress). When the PID counter wraps around and the tool accidentally gets the same PID as another process that got killed by SIGTERM, the new test process will fail during IPC setup. lib/tst_test.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/tst_test.c b/lib/tst_test.c index b225ba082..1732fd058 100644 --- a/lib/tst_test.c +++ b/lib/tst_test.c @@ -1568,6 +1568,7 @@ static int fork_testrun(void) int status; SAFE_SIGNAL(SIGINT, sigint_handler); + SAFE_SIGNAL(SIGTERM, sigint_handler); alarm(results->timeout); @@ -1579,6 +1580,7 @@ static int fork_testrun(void) tst_disable_oom_protection(0); SAFE_SIGNAL(SIGALRM, SIG_DFL); SAFE_SIGNAL(SIGUSR1, SIG_DFL); + SAFE_SIGNAL(SIGTERM, SIG_DFL); SAFE_SIGNAL(SIGINT, SIG_DFL); SAFE_SETPGID(0, 0); testrun(); @@ -1586,6 +1588,7 @@ static int fork_testrun(void) SAFE_WAITPID(test_pid, &status, 0); alarm(0); + SAFE_SIGNAL(SIGTERM, SIG_DFL); SAFE_SIGNAL(SIGINT, SIG_DFL); if (tst_test->taint_check && tst_taint_check()) {