Why does pressing Ctrl-backslash result in core dump? Why does pressing Ctrl-backslash result in core dump? python python

Why does pressing Ctrl-backslash result in core dump?


CTRL-\ is the Linux key that generates the QUIT signal. Generally, that signal causes a program to terminate and dump core. This is a feature of UNIX and Linux, wholly unrelated to Python. (For example, try sleep 30 followed by CTRL-\.)

If you want to disable that feature, use the stty command.

From the Linux command line, before Python starts:

stty quit undef


The python module signal is convenient to deal with this.

import signal# Intercept ctrl-c, ctrl-\ and ctrl-zdef signal_handler(signal, frame):    passsignal.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.