Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- set -e
- declare -ai pids=()
- ten_seconds() {
- sleep 10s
- }
- twenty_seconds() {
- sleep 20s
- }
- for ((i=0; i < $1; i++)); do ten_seconds & pids+=($!); twenty_seconds & pids+=($!); printf "\rwaiting for %d processes to exit" "$(($i + 1))"; done
- for p in "${pids[@]}"; do wait -n; printf "done: %d\n" "$p"; done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement