Skip to content

Commit

Permalink
Fixed bugs about defunct processes and mis-coding (yahoojapan#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggtakec authored Dec 6, 2024
1 parent b533cc8 commit 236d813
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
6 changes: 4 additions & 2 deletions bin/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ stop_old_process()
# If processes are running yet, try to kill it.
#
for _ONE_PID in ${ALL_CHILD_PIDS}; do
if ps -p "${_ONE_PID}" >/dev/null 2>&1; then
# shellcheck disable=SC2009
if ! ps -ax | grep -v grep | grep -v defunct | grep -q "${_ONE_PID}"; then
kill -KILL "${_ONE_PID}" >/dev/null 2>&1
fi
done
Expand All @@ -163,7 +164,8 @@ stop_old_process()
# Result
#
for _ONE_PID in ${ALL_CHILD_PIDS}; do
if ps -p "${_ONE_PID}" >/dev/null 2>&1; then
# shellcheck disable=SC2009
if ! ps -ax | grep -v grep | grep -v defunct | grep -q "${_ONE_PID}"; then
echo "[ERROR] Could not stop old processes."
return 1
fi
Expand Down
1 change: 1 addition & 0 deletions lib/openstackapiv3.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ function rawGetUserUnscopedTokenV3(uname, passwd, callback)
resobj.region = keystone_ep.region.toLowerCase();
resobj.token_seed = JSON.stringify({ publisher: 'OPENSTACKV3' });
_callback(null, resobj);
return;
});
});
req.on('error', function(exception) {
Expand Down
12 changes: 8 additions & 4 deletions tests/auto_control_subprocess.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ if [ "${EXEC_MODE}" = "start" ]; then
sleep "${RUN_INTERVAL}"
fi

if ! ps -p "${CHILD_PROCESS_PID}" >/dev/null 2>&1; then
# shellcheck disable=SC2009
if ! ps -ax | grep -v grep | grep -v defunct | grep -q "${CHILD_PROCESS_PID}"; then
echo "[ERROR] Could not start child process : ${CHILD_PROCESS_CMD}"
exit 1
fi
Expand All @@ -189,7 +190,8 @@ else

CHILD_PROCESS_PID="$(tr -d '\n' < "${CHILD_PROCESS_PIDFILE}")"

if ps -p "${CHILD_PROCESS_PID}" >/dev/null 2>&1; then
# shellcheck disable=SC2009
if ! ps -ax | grep -v grep | grep -v defunct | grep -q "${CHILD_PROCESS_PID}"; then
#
# Try stop
#
Expand All @@ -200,7 +202,8 @@ else
sleep "${RUN_INTERVAL}"
fi

if ps -p "${CHILD_PROCESS_PID}" >/dev/null 2>&1; then
# shellcheck disable=SC2009
if ! ps -ax | grep -v grep | grep -v defunct | grep -q "${CHILD_PROCESS_PID}"; then
#
# Retry stop
#
Expand All @@ -211,7 +214,8 @@ else
sleep "${RUN_INTERVAL}"
fi

if ps -p "${CHILD_PROCESS_PID}" >/dev/null 2>&1; then
# shellcheck disable=SC2009
if ! ps -ax | grep -v grep | grep -v defunct | grep -q "${CHILD_PROCESS_PID}"; then
echo "[ERROR] Could not stop process : ${CHILD_PROCESS_NAME}"
exit 1
fi
Expand Down

0 comments on commit 236d813

Please sign in to comment.