fork download
  1. #!/bin/bash
  2.  
  3. update() {
  4. local i="$1"
  5.  
  6. echo "./update.sh $i"
  7. }
  8.  
  9. loop_func() {
  10. local d;
  11.  
  12. for d in {2..40}; do
  13. update $d 1>&2 &
  14. echo $!
  15. done
  16. }
  17.  
  18. pids=( $(loop_func) )
  19. wait ${pids[@]} &>/dev/null
  20. echo "d: $d"
Success #stdin #stdout #stderr 0s 5048KB
stdin
Standard input is empty
stdout
d: 
stderr
./prog.sh: fork: retry: Resource temporarily unavailable
./update.sh 4
./update.sh 6
./update.sh 7
./update.sh 8
./update.sh 9
./update.sh 10
./update.sh 11
./update.sh 12
./update.sh 13
./update.sh 14
./update.sh 15
./update.sh 16
./update.sh 17
./update.sh 18
./update.sh 19
./update.sh 5
./update.sh 3
./update.sh 20
./update.sh 22
./update.sh 23
./update.sh 24
./update.sh 25
./update.sh 26
./update.sh 27
./update.sh 28
./update.sh 29
./update.sh 21
./update.sh 2
./prog.sh: fork: retry: No child processes
./update.sh 30
./update.sh 31
./update.sh 32
./update.sh 33
./update.sh 34
./update.sh 35
./update.sh 36
./update.sh 37
./update.sh 39
./update.sh 40
./prog.sh: line 19: /dev/null: Permission denied
./update.sh 38