[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-dejagnu] close_wait_program, process groups and kill /bin/sh builti
From: |
Richard Biener |
Subject: |
[Bug-dejagnu] close_wait_program, process groups and kill /bin/sh builtin |
Date: |
Thu, 5 Jul 2018 12:24:32 +0200 (CEST) |
User-agent: |
Alpine 2.20 (LSU 67 2015-01-07) |
Hi,
I have noticed several issues with close_wait_program in that processes
are not reliably killed after timeout. First of all is
# Prepend "-" to generate the "process group ID" needed by
# kill.
set pgid "-$pid"
doesn't properly deal with $pid being a list of pids, there's related
code that does the correct thing in local_exec:
# Prepend "-" to each pid, to generate the "process group IDs" needed
by
# kill.
set pgid "-[join $pid { -}]"
verbose "pid is $pid $pgid"
Then close_wait_program executes
set sh_cmd "exec > /dev/null 2>&1"
append sh_cmd " && sleep $secs && (kill -15 $pgid || kill -15
$pid)"
append sh_cmd " && sleep $secs && (kill -9 $pgid || kill -9 $pid)"
which on my system does
12702 execve("/usr/bin/sh", ["sh", "-c", "exec > /dev/null 2>&1 && (kill
-2 -1351 1352 || kill -2 1351 1352)"], [/* 126 vars */] <unfinished ...>
with /usr/bin/sh being bash. Now, the bash kill builtin behaves
differently to the standalone command which documents
RETURN CODES
..
64 partial success (when more than one process specified)
while bash documents
kill returns true
if at least one signal was successfully sent, or false if
an
error occurs or an invalid option is encountered.
so for me the first kill command 'kill -2 -1351 1352' succeeds
but fails to kill the timed out process 1351.
So my suggestion is to first fix the pgid computation (which would
probably solve my other issue as well), then to either avoid
using shell builtins by doing && (env kill -15 ... or to not rely
on the particular semantics of multiple process kills and somehow
iterate over $pid/$pgid.
Thanks,
Richard.
--
Richard Biener <address@hidden>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB
21284 (AG Nuernberg)
- [Bug-dejagnu] close_wait_program, process groups and kill /bin/sh builtin,
Richard Biener <=