Created
July 24, 2021 19:04
-
-
Save ormaaj/ea10dab9724e1cd05823e2514b7a3951 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bash -o monitor -O lastpipe /dev/fd/3 3<<\EOF | |
typeset -A j jobs | |
n=0 | |
while ((n++ < 3)); do | |
{ set -m; trap "exit \$n" exit; suspend; } & | |
jobs+=([$!]=) | |
done | |
{ for x in "${!jobs[@]}"; do sleep .2; kill -CONT "$x"; done; } & | |
until wait -fnp jid "${!jobs[@]}" | |
(( (${jobs[$jid]+j[\$jid] = }$?) == 0)); do | |
unset -v "jobs[\$jid]" jid | |
done | |
typeset -p j | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment