Skip to content

Commit 9683af5

Browse files
authored
Allow graceful killing of processes
1 parent d3c9b9f commit 9683af5

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

dev/ofunctions.sh

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -388,16 +388,17 @@ function KillChilds {
388388
kill -s TERM "$pid"
389389
Logger "Sent SIGTERM to process [$pid]." "DEBUG"
390390
if [ $? -ne 0 ]; then
391-
sleep 15
392-
Logger "Sending SIGTERM to process [$pid] failed." "DEBUG"
393-
kill -9 "$pid"
394-
if [ $? -ne 0 ]; then
395-
Logger "Sending SIGKILL to process [$pid] failed." "DEBUG"
396-
return 1
397-
fi # Simplify the return 0 logic here
398-
else
399-
return 0
400-
fi
391+
sleep 60 # Arbitrary wait time to let process terminate gracefully
392+
if kill -0 "$pid" > /dev/null 2>&1; then
393+
Logger "Sending SIGTERM to process [$pid] failed." "DEBUG"
394+
kill -9 "$pid"
395+
if [ $? -ne 0 ]; then
396+
Logger "Sending SIGKILL to process [$pid] failed." "DEBUG"
397+
return 1
398+
fi # Simplify the return 0 logic here
399+
else
400+
return 0
401+
fi
401402
else
402403
return 0
403404
fi

0 commit comments

Comments
 (0)