Skip to content

Instantly share code, notes, and snippets.

@jmtd
Created October 16, 2015 10:00
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 jmtd/381306acafd16e656d1a to your computer and use it in GitHub Desktop.
Save jmtd/381306acafd16e656d1a to your computer and use it in GitHub Desktop.
blah
echo parent pid is $BASHPID
bollocks() {
pidfile=$(mktemp -t bollocks.XXXXXX)
ls -ld "$pidfile"
(
echo $BASHPID | tee "$pidfile"
sleep 30
rm "$pidfile"
) &
count=0
timeout=5
while test -e "$pidfile"; do
if [ "$count" -ge "$timeout" ]; then
echo "giving up, DIE DIE"
kill -9 $(cat "$pidfile")
break
fi
echo "parent: still there..."
((count += 1))
sleep 1
done
echo "it's gone!"
}
bollocks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment