Created
June 8, 2016 07:42
-
-
Save cslarsen/f7a92694ed445e9e881c9fed73b87cdc to your computer and use it in GitHub Desktop.
BASH program that waits until given PIDs have terminated. Rename to pwait and chmod +x.
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 | |
if [ $# -eq 0 ]; then | |
echo "Usage: pwait <PID>" | |
echo "Waits until PID has terminated, then continues." | |
echo "Example: pwait 123 && echo DONE" | |
exit 1 | |
fi | |
for pid in "$@"; do | |
while [ -e /proc/$pid ]; do | |
sleep 0.1 | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment