Merge pull request #11629 from paulozulato/fix-zombie-process-checking
fix: handle case that zombie process terminated
This commit is contained in:
commit
f05814b230
12
bin/emqx
12
bin/emqx
|
@ -805,6 +805,12 @@ generate_config() {
|
||||||
mv -f "$TMP_ARG_FILE" "$ARGS_FILE"
|
mv -f "$TMP_ARG_FILE" "$ARGS_FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# check if a PID is defunct
|
||||||
|
is_defunct() {
|
||||||
|
local PID="$1"
|
||||||
|
ps -fp "$PID" | $GREP -q 'defunct'
|
||||||
|
}
|
||||||
|
|
||||||
# check if a PID is down
|
# check if a PID is down
|
||||||
# shellcheck disable=SC2317 # call in func `nodetool_shutdown()`
|
# shellcheck disable=SC2317 # call in func `nodetool_shutdown()`
|
||||||
is_down() {
|
is_down() {
|
||||||
|
@ -812,9 +818,13 @@ is_down() {
|
||||||
if ps -p "$PID" >/dev/null; then
|
if ps -p "$PID" >/dev/null; then
|
||||||
# still around
|
# still around
|
||||||
# shellcheck disable=SC2009 # this grep pattern is not a part of the program names
|
# shellcheck disable=SC2009 # this grep pattern is not a part of the program names
|
||||||
if ps -fp "$PID" | $GREP -q 'defunct'; then
|
if is_defunct "$PID"; then
|
||||||
# zombie state, print parent pid
|
# zombie state, print parent pid
|
||||||
parent="$(ps -o ppid= -p "$PID" | tr -d ' ')"
|
parent="$(ps -o ppid= -p "$PID" | tr -d ' ')"
|
||||||
|
if [ -z "$parent" ] && ! is_defunct "$PID"; then
|
||||||
|
# process terminated in the meanwhile
|
||||||
|
return 0;
|
||||||
|
fi
|
||||||
logwarn "$PID is marked <defunct>, parent: $(ps -p "$parent")"
|
logwarn "$PID is marked <defunct>, parent: $(ps -p "$parent")"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue