$ bash -x wait.sh
+ sleep 2
+ wait
+ sleep 1
+ echo foo
foo
+ echo bar
bar
+ echo hogehoge
hogehoge
Last active
February 10, 2016 03:41
-
-
Save tkuchiki/423bf529abf041438f74 to your computer and use it in GitHub Desktop.
wait コマンドの実験結果
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sleep 2 && echo "bar" & | |
sleep 1 && echo "foo" & | |
wait | |
echo "hogehoge" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sleep 5 && awk 'END { exit 5 }' & | |
pid1=$! | |
sleep 1 && awk 'END { exit 1 }' & | |
pid2=$! | |
sleep 3 && awk 'END { exit 3 }' & | |
pid3=$! | |
wait $pid1 | |
echo $? | |
wait $pid2 | |
echo $? | |
wait $pid3 | |
echo $? |
$ bash -x wait_pid.sh
+ pid1=9559
+ sleep 5
+ pid2=9560
+ sleep 1
+ pid3=9562
+ wait 9559
+ sleep 3
+ awk 'END { exit 1 }'
+ awk 'END { exit 3 }'
+ awk 'END { exit 5 }'
+ echo 5
5
+ wait 9560
+ echo 1
1
+ wait 9562
+ echo 3
3
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment