Created
November 17, 2017 19:56
-
-
Save adeubank/e526a5ef9255f2d32b205552cbe5b3c9 to your computer and use it in GitHub Desktop.
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 | |
# | |
# USAGE: wait_until_done PID | |
# | |
# wait_until_done watches a process passed in as the first argument waits until | |
# it finishes | |
# | |
# Print the header comment from this file, ducking the shebang line, and stopping a the first line that doesn't start with a hash | |
function print_header_comment { | |
awk '/^# / { print substr( $0, 3 ) }; $0 !~ /^#/ { exit }' $0 | |
} | |
# Print Usage or Execute | |
if [ $# == 0 ]; then | |
print_header_comment | |
else | |
PID=$1 | |
while kill -0 $PID 2> /dev/null; do | |
sleep 10 | |
done | |
echo | |
echo "Process $PID finished..." | |
echo | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment