From 0ce5af2bc4513082508de4f69fa9bc2d14ab1cff Mon Sep 17 00:00:00 2001 From: stormdragon2976 Date: Mon, 30 Jan 2023 20:34:00 -0500 Subject: [PATCH] Fix up the background process handler. --- ratatoskr.sh | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) 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