diff --git a/stream.sh b/stream.sh index 1a928f1..ee16ce2 100755 --- a/stream.sh +++ b/stream.sh @@ -12,9 +12,20 @@ fi declare -A STREAMS +sigint() { + for pid in "${STREAMS[@]}"; do + wait "$pid" + done +} + +trap sigint INT + failed() { - echo "Streaming $1 failed" - tail -n 5 "/tmp/$1_log" + file=$1 + echo "Streaming $file failed" + tail -n 5 "/tmp/${file}_log" + + unset "STREAMS[$file]" } streaming() { @@ -31,6 +42,8 @@ streaming() { > "/tmp/$1_log" \ 2>&1 ) || failed "$1" + + unset "STREAMS[$file]" } check() {