From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6B58739FC82E; Thu, 22 Apr 2021 11:19:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6B58739FC82E From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug testsuite/100203] Dejagnu timeouts don't work Date: Thu, 22 Apr 2021 11:19:16 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: testsuite X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Apr 2021 11:19:16 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100203 --- Comment #2 from Jonathan Wakely --- This seems to be a bug in the Bash 'kill' builtin. #!/bin/bash # pass /usr/bin/kill as $1 to use the command not the bash builtin kill=3D${1:-kill} sleep 60 & pid1=3D$! sleep 60 & pid2=3D$! sh -c "exec > /dev/stdout 2>&1 && ($kill -15 -$pid1 $pid2 || { echo kill pg= rp failed, trying again... ; $kill -15 $pid1 $pid2 || echo $?;})" ps -ef | awk 'NR=3D=3D1 || /[s]leep/ {print}' kill $pid1 $pid2 2>/dev/null Run without arguments, this script prints something like: sh: line 0: kill: (-2977556) - No such process UID PID PPID C STIME TTY TIME CMD jwakely 2977556 2977555 0 12:14 pts/2 00:00:00 sleep 60 i.e. the first kill command kills $pid2 but fails to kill -$pid1 (because t= here is no such process group) but it exits with status 0, so we don't try again just $pid1 instead of -$pid1 Passing /usr/bin/kill as $1 to the script we get: kill: sending signal to -2977547 failed: No such process kill pgrp failed, trying again... kill: sending signal to 2977548 failed: No such process 0 UID PID PPID C STIME TTY TIME CMD i.e. the first kill command kills $pid2 and fails to kill -$pid1 (as before= ), but because it was only partial success it exits with non-zero status, and = we try again using $pid1 instead of -$pid1. That second command succeeds in killing $pid1 this time, but gives and error for $pid2 (because it was alre= ady killed). POSIX says: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/kill.html The following exit values shall be returned: 0 At least one matching process was found for each pid operand, and t= he specified signal was successfully processed for at least one matching proce= ss. >0 An error occurred. The Bash builtin seems to be wrong here, because no matching process was fo= und for -$pid1 so it should not return 0.=