Skip to content

Commit

Permalink
fix bug: docker script execution didn't return when terminated. #84
Browse files Browse the repository at this point in the history
  • Loading branch information
miyosuda committed Oct 5, 2018
1 parent e5719a7 commit 4e9136f
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions helpers/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,22 @@ else
while ! xdpyinfo -display "${DISPLAY}" > /dev/null 2>&1; do
sleep 0.1
done

# Execute passed command.
"$@" &
cmd_pid=$!
trap "echo 'Stopping'; kill -SIGTERM $Xvfb_pid $cmd_pid" SIGINT SIGTERM
# Wait for process to end.
while kill -0 $Xvfb_pid $cmd_pid > /dev/null 2>&1; do
wait

# Catch Ctrl-C interrupt and then kill process
trap "echo 'Stopping'; kill -s TERM $Xvfb_pid $cmd_pid" INT TERM

# Wait for command process to end.
while kill -0 $cmd_pid > /dev/null 2>&1; do
# Wait for command process to finish.
wait $cmd_pid
done

if kill -0 $Xvfb_pid > /dev/null 2>&1; then
# Kill Xfvb process
kill -s TERM $Xvfb_pid
fi
fi

0 comments on commit 4e9136f

Please sign in to comment.