Currently whenever I press CTRL + Z
on a lengthy script I was given, it immediately terminates the script ([1+]
stopped(SIGTSTP
) ./test.py
) which is what I want, but it also leaves the python2
process running (when I type ps to look at processes), which forces me to use killall -9 python2
, which I do not want to do every time. Is there a way to immediately terminate a script that doesn't leave the python2 process running in the background?
There is no SIGTSTP
currently in the code that I see but I did try using the following code with no luck. It didn't even exit the script when I pressed CTRL + Z
.
def handler(signum, frame):
sys.exit("CTRL+Z pressed. Exiting Test")
signal.signal(signal.SIGTSTP, handler)