Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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