Skip to content

Instantly share code, notes, and snippets.

@daveadams
Created October 12, 2016 12:29
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 daveadams/d1282f87e0de318353076539a1dd496d to your computer and use it in GitHub Desktop.
Save daveadams/d1282f87e0de318353076539a1dd496d to your computer and use it in GitHub Desktop.
#!/bin/bash
# via: http://askubuntu.com/a/421028
# original: https://bugs.launchpad.net/upstart/+bug/406397/comments/47
# usage: sh /tmp/upstart_fix.sh <pid>
sleep 0.001 &
firstPID=$!
#first lets exhaust the space
while (( $! >= $firstPID ))
do
sleep 0.001 &
done
# [ will use testPID itself, we want to use the next pid
declare -i testPID
testPID=$(($1 - 1))
while (( $! < $testPID ))
do
sleep 0.001 &
done
# fork a background process then die so init reaps its pid
sleep 3 &
echo "Init will reap PID=$!"
kill -9 $$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment