×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Bash
Posted by: Solr Trovaprezzi
Added: May 13, 2016 9:19 AM
Views: 12
Tags: bash wait process
  1. #!/bin/bash
  2.  
  3. function doCalculations {
  4.   echo $1
  5.   sleep 10;
  6. }
  7.  
  8. pids=""
  9.  
  10. for i in `seq 0 9`; do
  11.    doCalculations $i &
  12.    pids="$pids $!"
  13. done
  14.  
  15. wait $pids
  16.  
  17. echo "Waited for all subprocesses"
  18.