Skip to content

Instantly share code, notes, and snippets.

@adeubank
Created November 17, 2017 19:56
Show Gist options
  • Save adeubank/e526a5ef9255f2d32b205552cbe5b3c9 to your computer and use it in GitHub Desktop.
Save adeubank/e526a5ef9255f2d32b205552cbe5b3c9 to your computer and use it in GitHub Desktop.
#!/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