Skip to content

Commit

Permalink
Merge pull request #4 from kronostechnologies/DOPS-5351/ignore-bash-p…
Browse files Browse the repository at this point in the history
…rocesses-for-sig-term

DOPS-5351: ignore bash processes from sig term loop
  • Loading branch information
cdadoua1409 authored Jan 21, 2025
2 parents 52362ca + 77b8cf8 commit 7f8cc90
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ process_scripts() {
kill_remaining_process() {
# Gather all PIDs except for pid 1 (entrypoint script) into a
# space separated list, send SIGTERM and wait for those process to finish properly
# ignore the process if it is a bash shell
ps -e > /tmp/ps
local PIDS=`grep -v -E "PID|\s1\s|ps" /tmp/ps | awk 'BEGIN { ORS=" " }; {print $1}'`;
rm /tmp/ps

if [ -n "$PIDS" ]; then
kill -TERM $PIDS
for PID in $PIDS; do
processName=$(cat /proc/$PID/cmdline)
echo "> Waiting for process $PID ($processName) to finish.."
if [[ "$processName" == "bash" ]]; then
echo "> Skipping bash shell process.."
continue
fi
while [[ -d /proc/$PID ]]; do
sleep 0.1
done
Expand Down

0 comments on commit 7f8cc90

Please sign in to comment.