public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview] Message-ID: <bug-100203-4-yvqXkKrLgl@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-100203-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100203 --- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- 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=${1:-kill} sleep 60 & pid1=$! sleep 60 & pid2=$! sh -c "exec > /dev/stdout 2>&1 && ($kill -15 -$pid1 $pid2 || { echo kill pgrp failed, trying again... ; $kill -15 $pid1 $pid2 || echo $?;})" ps -ef | awk 'NR==1 || /[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 there 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 already 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 the specified signal was successfully processed for at least one matching process. >0 An error occurred. The Bash builtin seems to be wrong here, because no matching process was found for -$pid1 so it should not return 0.
next prev parent reply other threads:[~2021-04-22 11:19 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-04-22 10:46 [Bug testsuite/100203] New: " jakub at gcc dot gnu.org 2021-04-22 11:03 ` [Bug testsuite/100203] " jakub at gcc dot gnu.org 2021-04-22 11:19 ` redi at gcc dot gnu.org [this message] 2021-04-22 11:23 ` jakub at gcc dot gnu.org 2021-04-22 11:26 ` redi at gcc dot gnu.org 2021-04-22 11:38 ` redi at gcc dot gnu.org 2021-04-22 11:59 ` redi at gcc dot gnu.org 2021-04-22 15:15 ` msebor at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-100203-4-yvqXkKrLgl@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).