diff --git a/dev/ofunctions.sh b/dev/ofunctions.sh index 6eb6c25..1bb5006 100755 --- a/dev/ofunctions.sh +++ b/dev/ofunctions.sh @@ -388,16 +388,17 @@ function KillChilds { kill -s TERM "$pid" Logger "Sent SIGTERM to process [$pid]." "DEBUG" if [ $? -ne 0 ]; then - sleep 15 - Logger "Sending SIGTERM to process [$pid] failed." "DEBUG" - kill -9 "$pid" - if [ $? -ne 0 ]; then - Logger "Sending SIGKILL to process [$pid] failed." "DEBUG" - return 1 - fi # Simplify the return 0 logic here - else - return 0 - fi + sleep 60 # Arbitrary wait time to let process terminate gracefully + if kill -0 "$pid" > /dev/null 2>&1; then + Logger "Sending SIGTERM to process [$pid] failed." "DEBUG" + kill -9 "$pid" + if [ $? -ne 0 ]; then + Logger "Sending SIGKILL to process [$pid] failed." "DEBUG" + return 1 + fi # Simplify the return 0 logic here + else + return 0 + fi else return 0 fi