Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward SIGTERM and SIGINT in wrapper script #746

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion omxplayer
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,21 @@ DBUS_SESSION_BUS_PID=`cat $OMXPLAYER_DBUS_PID`
export DBUS_SESSION_BUS_ADDRESS
export DBUS_SESSION_BUS_PID

LD_LIBRARY_PATH="$OMXPLAYER_LIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" $OMXPLAYER_BIN "$@"
# Propagate SIGTERM and SIGINT to the player and while still allowing cleanup
# Approach taken from http://veithen.io/2014/11/16/sigterm-propagation.html
trap 'kill -TERM $OMXPLAYER_PID' TERM INT
# Start omxplayer in the background, otherwise bash will ignore signals
LD_LIBRARY_PATH="$OMXPLAYER_LIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" $OMXPLAYER_BIN "$@"&
OMXPLAYER_PID=$!
# Wait for omxplayer to complete
wait $OMXPLAYER_PID
# When a signal arrives, the wait will be interrupted, but omxplayer
# might not be terminated yet. Remove our signal handler and wait again
# to make sure omxplayer is really terminated. When it was already
# terminated, wait just returns the exit code.
trap - TERM INT
wait $OMXPLAYER_PID
# Store the omxplayer exit code
RESULT=$?

if [ ! -z $NOREFRESH ] && [ "$NOREFRESH" == "1" ]; then
Expand Down