Last active
December 16, 2015 13:57
-
-
Save hashmap/046c0efb6abe21702a5b to your computer and use it in GitHub Desktop.
Manual test for story #108987020
This file contains hidden or 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
package main | |
import ( | |
"fmt" | |
"os" | |
"os/signal" | |
"strconv" | |
"time" | |
) | |
func main() { | |
fmt.Println(strconv.Itoa(os.Getpid())) | |
signal.Ignore() | |
for { | |
time.Sleep(5 * time.Second) | |
} | |
} |
This file contains hidden or 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
function pid_exists() { | |
ps -p $1 &> /dev/null | |
} | |
PID=$(head -1 $1) | |
if [ ! -z $PID ] && pid_exists $PID; then | |
kill $PID | |
fi | |
TRIES=0 | |
while [ -e /proc/$PID ] | |
do | |
TRIES=$(( $TRIES + 1 )) | |
if [ $TRIES -gt 100 ]; then | |
kill -9 $PID | |
fi | |
sleep 0.1 | |
done | |
rm -f $PIDFILE |
This file contains hidden or 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
$ go run immortal.go > pid & | |
$ ./stop.sh pid | |
signal: killed | |
[1]+ Exit 1 go run immortal.go > pid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment