| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | mode=$1 |
| 4 | nchildren=$2 |
| 5 | sleeptime=$3 |
| 6 | |
| 7 | # Ensure at least one background process for `wait` to track, we want this to take longer than the children. |
| 8 | long_sleep=$(awkscip-shell system . . awk. "BEGIN {print $sleeptime * 1.5}") |
| 9 | sleepscip-shell system . . sleep. "$long_sleep" & |
| 10 | |
| 11 | for _ in $(seqscip-shell system . . seq. 1 "$nchildren"); do |
| 12 | case "$mode" in |
| 13 | subshell) |
| 14 | ( sleepscip-shell system . . sleep. "$sleeptime" & ) ;; |
| 15 | nohup) |
| 16 | ( nohupscip-shell system . . nohup. sleep "$sleeptime" & disown ) & ;; |
| 17 | setsid) |
| 18 | setsidscip-shell system . . setsid. sleep "$sleeptime" & ;; |
| 19 | plain) |
| 20 | sleepscip-shell system . . sleep. "$sleeptime" & ;; |
| 21 | *) |
| 22 | echoscip-shell system . . echo. "Unknown mode: $mode" >&2 |
| 23 | exit 1 |
| 24 | ;; |
| 25 | esac |
| 26 | done |
| 27 | |
| 28 | wait |