Hello, I have been trying to figure out why the wait isnt waiting for the sleep process to complete till now and have found out that since sleep runs as different process and not a child process the wait isnt waiting.
script:
cat test|while read i
do
echo $i
sleep 30 &
done
wait
ps -ef|grep sleep
The output of the above script is
1 ab
2 bc
3 cd
4 de
user 24553 1 0 06:15 pts/3 00:00:00 sleep 30
user 24554 1 0 06:15 pts/3 00:00:00 sleep 30
user 24555 1 0 06:15 pts/3 00:00:00 sleep 30
user 24556 1 0 06:15 pts/3 00:00:00 sleep 30
user 24558 24550 0 06:15 pts/3 00:00:00 grep sleep
Can somebody please let me know how I can have the sleep command run as a child process so that the wait command works and the output of the script wont show any sleep processes running in the background.
