From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS15576 212.103.64.0/19 X-Spam-Status: No, score=-3.3 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from mx.kolabnow.com (mx.kolabnow.com [212.103.80.153]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 48E4F1F4D7 for ; Fri, 10 Jun 2022 15:39:37 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (4096-bit key; secure) header.d=kolabnow.com header.i=@kolabnow.com header.b="6IJsmGQ4"; dkim-atps=neutral Received: from localhost (unknown [127.0.0.1]) by mx.kolabnow.com (Postfix) with ESMTP id ADCD7404C5; Fri, 10 Jun 2022 17:39:35 +0200 (CEST) Authentication-Results: ext-mx-out003.mykolab.com (amavisd-new); dkim=pass (4096-bit key) reason="pass (just generated, assumed good)" header.d=kolabnow.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kolabnow.com; h= content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:date:subject:subject:from:from:received :received:received; s=dkim20160331; t=1654875575; x=1656689976; bh=8AwKwVc9qPzsv3ItyC8VSuLOLuLSx8olsUZ7bp3qD18=; b=6IJsmGQ4TvOi Q4NUatEEWc9ySHnUwgBkukcugktk75DwOkQgMN9oSrAFSpQEuq0EXm7LQf30aLzn Kil+KuITYnZvENdrI4C/snxx/5a6ffQ7vw8NIv1AzjC9Pij9R5dEmGMj6bzembP+ RqmV5zSpdpxfpZw5uaxveWw4sLQy7JlYT3Xku7AQcBbNNcYBp7dCAps2MLUMzsWr F9TLXSksDjwC8sAV5pvaG4CB0f3rYVwbEqqRpAyRAsmtCAlI9krdv5yZI25u5nqx wzcLczHYdKOZvqsNV/RVvWKuUNrJ6AepAg0OBJsFJVULTU23QzdK9sOe8YAhKCwF zyji8yCYnZZlxOcfZVRmHArk72J1bymFkKX0CxycA60cJFA92I+D8lg7BrB4LWu6 zcEqTyVGkAxIi6nPSZJz8mTh8smp/uyBWyX4pQMMdVcKmPwP98o3Cm+BePZcXeLK HmuvMEKeM2hToWXg9eGbG4MpA8MFEBrtihAGkxNS6flc4vJel1kiCfiAzMPI1nzn h3Izzjpy+LDoquNItXqqgvvysPs1dAIcy0bk5ip1qGE1mZnYhFkhn00aa5RM098c tidK0IBUiUFODenZvOh6bU0ihSB1aA8FxxR+ifzjOZWa2gxE+NvmtPm3XN5sh9cu xYQhaATn6vDRN1X7z7E4NxoQt0VkphQ= X-Virus-Scanned: amavisd-new at mykolab.com Received: from mx.kolabnow.com ([127.0.0.1]) by localhost (ext-mx-out003.mykolab.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id h3-BqVmDFzJf; Fri, 10 Jun 2022 17:39:35 +0200 (CEST) Received: from int-mx003.mykolab.com (unknown [10.9.13.3]) by mx.kolabnow.com (Postfix) with ESMTPS id 9EF0840392; Fri, 10 Jun 2022 17:39:34 +0200 (CEST) Received: from ext-subm002.mykolab.com (unknown [10.9.6.2]) by int-mx003.mykolab.com (Postfix) with ESMTPS id 364D42367; Fri, 10 Jun 2022 17:39:34 +0200 (CEST) From: Thiago Jung Bauermann To: meta@public-inbox.org Cc: Eric Wong , Thiago Jung Bauermann Subject: [PATCH v2] t/spawn: Find invalid PID to try to join its process group Date: Fri, 10 Jun 2022 12:39:18 -0300 Message-Id: <20220610153918.165014-1-bauermann@kolabnow.com> In-Reply-To: <874k0s5yia.fsf@kolabnow.com> References: <874k0s5yia.fsf@kolabnow.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: In the container used to build packages of the GNU Guix distribution, PID 1 runs as the same user as the test so this spawn that should fail actually succeeds. Fix the problem by going through different PIDs and picking one that either doesn't exist or we aren't allowed to signal. --- Hello, This version incorporates Eric's feedback. I also took the opportunity to add a comment explaining what the purpose of that particular spawn invocation is. I wasn't familiar with the code so it wasn't immediately obvious to me. I hope I got the comment right. Changes since v1: - Start PID search at 0x7fffffff. - Changed indentation to all tabs. - Added comment explaining purpose of the spawn invocation. t/spawn.t | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/t/spawn.t b/t/spawn.t index 6168c1f6171c..5fc99a2a101c 100644 --- a/t/spawn.t +++ b/t/spawn.t @@ -24,7 +24,18 @@ SKIP: { is(waitpid($pid, 0), $pid, 'waitpid succeeds on spawned process'); is($?, 0, 'true exited successfully'); pipe(my ($r, $w)) or BAIL_OUT; - $pid = eval { spawn(['true'], undef, { pgid => 1, 2 => $w }) }; + + # Find invalid PID to try to join its process group. + my $wrong_pgid = 1; + for (my $i=0x7fffffff; $i >= 2; $i--) { + if (kill(0, $i) == 0) { + $wrong_pgid = $i; + last; + } + } + + # Test spawn behavior when it can't join the requested process group. + $pid = eval { spawn(['true'], undef, { pgid => $wrong_pgid, 2 => $w }) }; close $w; my $err = do { local $/; <$r> }; # diag "$err ($@)"; base-commit: 930d2dc63e04c652e3b64cc7f3b3a7d377637065