Add trap to wait for jobs to handle sigint

This commit is contained in:
Mathias Koehler 2023-04-29 20:37:39 +02:00
parent 09a2404fc3
commit 558100ae20
Signed by: interru
GPG key ID: E01E350F5E2A884A

View file

@ -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() {