diff --git a/ratatoskr.sh b/ratatoskr.sh index 87e492d..f94a728 100755 --- a/ratatoskr.sh +++ b/ratatoskr.sh @@ -4,12 +4,7 @@ # Let's see how far we can get. :) # Handle subprocesses that may not close with the main program. -trap cleanup EXIT -cleanup() { - if [[ $bgLoop -ne 0 ]]; then - trap 'pkill -P $$' EXIT - fi -} +trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT # Display usage information. @@ -191,7 +186,7 @@ done mkdir -p "${configPath}/soundpacks" # Keep track of the backgrounded loop -bgLoop=0 +bgLoop=1 # Associative array of command line parameters and short description of what they do. declare -A command=( @@ -233,9 +228,9 @@ done # Main loops # Display timelines and requested information. +# Important, set bgLoop to 0 or this loop will not close with the program +bgLoop=0 while : ; do - # Important, set bgLoop to 1 or this loop will not close with the program - bgLoop=1 if [[ -n "${since_id}" ]]; then result="$(curl -sS --oauth2-bearer "${oauth_token}" "${instanceURL}/api/va/timelines/${timeline:-home}?since_id=${since_id}")" else