Add trap to wait for jobs to handle sigint
This commit is contained in:
parent
09a2404fc3
commit
558100ae20
17
stream.sh
17
stream.sh
|
|
@ -12,9 +12,20 @@ fi
|
||||||
|
|
||||||
declare -A STREAMS
|
declare -A STREAMS
|
||||||
|
|
||||||
|
sigint() {
|
||||||
|
for pid in "${STREAMS[@]}"; do
|
||||||
|
wait "$pid"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
trap sigint INT
|
||||||
|
|
||||||
failed() {
|
failed() {
|
||||||
echo "Streaming $1 failed"
|
file=$1
|
||||||
tail -n 5 "/tmp/$1_log"
|
echo "Streaming $file failed"
|
||||||
|
tail -n 5 "/tmp/${file}_log"
|
||||||
|
|
||||||
|
unset "STREAMS[$file]"
|
||||||
}
|
}
|
||||||
|
|
||||||
streaming() {
|
streaming() {
|
||||||
|
|
@ -31,6 +42,8 @@ streaming() {
|
||||||
> "/tmp/$1_log" \
|
> "/tmp/$1_log" \
|
||||||
2>&1
|
2>&1
|
||||||
) || failed "$1"
|
) || failed "$1"
|
||||||
|
|
||||||
|
unset "STREAMS[$file]"
|
||||||
}
|
}
|
||||||
|
|
||||||
check() {
|
check() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue