The python module signal
is convenient to deal with this.
import signal
# Intercept ctrl-c, ctrl-\ and ctrl-z
def signal_handler(signal, frame):
pass
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGQUIT, signal_handler)
signal.signal(signal.SIGTSTP, signal_handler)
Just add handlers to the signal that (in this case) do nothing.