Created
February 13, 2015 11:56
-
-
Save biinari/4f4df8134d71d6c3236d to your computer and use it in GitHub Desktop.
Modified version of https://bugs.launchpad.net/upstart/+bug/406397/comments/47 to work with ubuntu sleep
This file contains 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: bash /tmp/upstart_fix_pid.sh <pid> | |
sleep 0.001 & | |
firstPID=$! | |
# exhaust the pid space | |
while (( $! >= $firstPID )) | |
do | |
sleep 0.001 & | |
done | |
# will use up to testPID inclusive, 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