mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 13:33:09 +07:00
test: reap the watchdog's sleep in wdkill()
Every test left a stray `sleep 300` behind, reparented to PID 1, where it lingered for up to five minutes after the test had finished. wdstart() runs the watchdog in a subshell, so $! is the pid of the subshell, not of the sleep it forks. wdkill() killed the subshell and orphaned the sleep. Kill the child first, killing the subshell puts the sleep beyond the reach of pkill -P. Neither kill is sure to match, and wdkill() runs from the EXIT trap under set -e, so both must tolerate failure. Also return early when wdpid is unset, for failures before wdstart() runs. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
+5
-1
@@ -255,8 +255,12 @@ wdstart()
|
||||
|
||||
wdkill()
|
||||
{
|
||||
[ -n "${wdpid:-}" ] || return 0
|
||||
|
||||
say "Stopping test watchdog, pid $wdpid"
|
||||
kill -KILL $wdpid
|
||||
# Reap the sleep first, killing its subshell orphans it to PID 1.
|
||||
pkill -KILL -P "$wdpid" 2>/dev/null || true
|
||||
kill -KILL "$wdpid" 2>/dev/null || true
|
||||
}
|
||||
|
||||
teardown()
|
||||
|
||||
Reference in New Issue
Block a user