Given these two functions:
$ foo () { for i in {1..10} ; do { sleep $i ; } & done ; wait ; }
$ bar () { echo {1..10} | tr ' ' '\n' | while read i ; do { sleep $i ;
} & done ; wait ; }
Why does foo take 10 seconds and bar is instant? Apparently, foo is
actually waiting for the background processes to finish, whereas bar
is not. Why not? And how can I get bar to act like foo, i.e. wait
for bg processes to finish)?
$ time -p foo 2> /dev/null
real 10.01
user 0.18
sys 0.03
$ time -p bar 2> /dev/null
real 0.00
user 0.02
sys 0.00
Regards,
- Robert
--
Central West End Linux Users Group (via Google Groups)
Main page: http://www.cwelug.org
To post: [email protected]
To subscribe: [email protected]
To unsubscribe: [email protected]
More options: http://groups.google.com/group/cwelug