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
|
||||
|
||||
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() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue