From 31b1646611d4fb67c656c8f483de7f5217c69091 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Mon, 9 Aug 2021 23:32:56 +0200 Subject: [PATCH] feat: inspect parent pid if emqx pid enters defunct state --- bin/emqx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/emqx b/bin/emqx index 37ad53f48..a286d2801 100755 --- a/bin/emqx +++ b/bin/emqx @@ -303,7 +303,15 @@ bootstrapd() { is_down() { PID="$1" if ps -p "$PID" >/dev/null; then - # still alive + # still around + # shellcheck disable=SC2009 # this grep pattern is not a part of the progra names + if ps -p "$PID" | grep -q 'defunct'; then + # zombie state, print parent pid + parent="$(ps -o ppid= -p "$PID" | tr -d ' ')" + echo "WARN: $PID is marked , parent:" + ps -p "$parent" + return 0 + fi return 1 fi # it's gone @@ -487,7 +495,6 @@ case "$1" in fi WAIT_TIME="${WAIT_FOR_ERLANG_STOP:-60}" if ! wait_for "$WAIT_TIME" 'is_down' "$PID"; then - ps -p "$PID" msg="dangling after ${WAIT_TIME} seconds" # also log to syslog logger -t "${REL_NAME}[${PID}]" "STOP: $msg"