import signal username = input('Username:') print(username)
$ python ctrl_c.py Username:^CTraceback (most recent call last): File "ctrl_c.py", line 3, in
username = input('Username:') KeyboardInterrupt
import signal def handler(signum, frame): print('Signal handler called with signal', signum) signal.signal(signal.SIGINT, handler) username = input('Username:') print(username)
- Cannot stop using Ctrl-C !
- Ctrl-Z and then kill %1
- kill PID