Last active
December 30, 2015 16:16
-
-
Save dnephin/a0a7a155fdea2ba17627 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
set -x | |
cat > tmp.py <<EOF | |
import os, signal | |
print os.getpid() | |
state = None | |
def handler(sig, frame): | |
global state | |
print "caught" | |
oldstate = state | |
state = "new" | |
if oldstate: | |
print "second" | |
else: | |
print "first" | |
signal.signal(signal.SIGTERM, handler) | |
while True: | |
pass | |
EOF | |
python tmp.py & | |
pid=$! | |
sleep 0.1 | |
parallel kill $pid ::: $pid ::: $pid | |
sleep 0.5 | |
kill -9 $pid | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment