Python – Why does pressing Ctrl-backslash result in core dump

backslashcoredumpctrlpython

When I'm in a python application (the python shell, for instance), pressing Ctrl\ results in

>>> Quit (core dumped)

Why is this, and how can I avoid this?
It is very inconvenient if application bails out whenever I press Ctrl\ by accident.

Best Answer

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