Skip to content

Instantly share code, notes, and snippets.

@ErwanAliasr1
Created March 23, 2016 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ErwanAliasr1/1969b33d2c538a65d8ed to your computer and use it in GitHub Desktop.
Save ErwanAliasr1/1969b33d2c538a65d8ed to your computer and use it in GitHub Desktop.
#!/bin/bash
pids=""
(sleep 10; exit 10) & pids="$pids $!"
(sleep 5; exit 5) & pids="$pids $!"
pids="$pids 9999"
for pid in $pids; do
wait $pid
echo "$pid returned $?"
done
@ErwanAliasr1
Copy link
Author

erwan@R1:~$ LC_ALL=C ./p.sh
24102 returned 10
24103 returned 5
./p.sh: line 10: wait: pid 9999 is not a child of this shell
9999 returned 127

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment