Ensure validator process is kill when stdout/stderr are redirected (#5179)

This commit is contained in:
Michael Vines 2019-07-18 21:18:48 -07:00 committed by GitHub
parent a12e7a2e33
commit cdbd1b908a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -371,13 +371,14 @@ PS4="$(basename "$0"): "
pid= pid=
kill_fullnode() { kill_fullnode() {
# Note: do not echo anything from this function to ensure $pid is actually
# killed when stdout/stderr are redirected
set +ex
if [[ -n $pid ]]; then if [[ -n $pid ]]; then
declare _pid=$pid declare _pid=$pid
pid= pid=
echo "killing pid $_pid"
kill "$_pid" || true kill "$_pid" || true
wait "$_pid" || true wait "$_pid" || true
echo "$_pid killed"
fi fi
} }
trap 'kill_fullnode' INT TERM ERR trap 'kill_fullnode' INT TERM ERR