wrappercheck.sh: enhanced killing of daemon

Occasionally the script shutdown got stuck on Ubuntu Vivid because killing
the background daemon failed although it was still runnning, thus causing the
wait to hang forever.

Not exactly sure what caused this. The enhancement tries to fall back to
killing the process instead of the process group (in case that there is
a race condition, which shouldn't be the case when waiting for the daemon),
preserves stderr from the kill commands and adds ps output when there is
an unexpected failure.
This commit is contained in:
Patrick Ohly 2015-03-03 00:53:59 -08:00
parent f4f83c1540
commit 096b7e61aa
1 changed files with 2 additions and 1 deletions

View File

@ -106,10 +106,11 @@ else
fi
( set +x; echo >&2 "*** killing and waiting for ${BACKGROUND[0]}" )
if kill -INT -$BACKGROUND_PID 2>/dev/null && kill -TERM -$BACKGROUND_PID 2>/dev/null; then
if kill -INT -$BACKGROUND_PID >&2 && kill -TERM -$BACKGROUND_PID >&2 || kill -INT $BACKGROUND_PID >&2 && kill -TERM $BACKGROUND_PID >&2; then
perl -e "sleep(60); kill(9, -$BACKGROUND_PID);" &
KILL_PID=$!
else
ps x --forest >&2
KILL_PID=
fi
set +e