
It seems that Python on Windows has been coded in such a way that CTRL + C is being processed as keyboard input rather than the SIGINT we are expecting. Thus, CTRL + C seems to be a SIGINT and its actions can be modified by the program you are running. This attribute of ignoring or not ignoring CTRL+C signals is inherited by child processes, but it can be enabled or disabled by any process without affecting existing processes. Normal CTRL+C processing is restored by calling SetConsoleCtrlHandler with NULL and FALSE values. When SetConsoleCtrlHandler is called with NULL and TRUE values for its parameters, the calling process ignores CTRL+C signals.The SetConsoleMode function can disable the ENABLE_PROCESSED_INPUT input mode for a console's input buffer, so CTRL+C is reported as keyboard input rather than as a signal.By default, when a console window has the keyboard focus, CTRL+C or CTRL+BREAK is treated as a signal (SIGINT or SIGBREAK) and not as keyboard input.ĬTRL+BREAK is always treated as a signal, but an application can change the default CTRL+C behavior in two ways that prevent the handler functions from being called: The CTRL+C and CTRL+BREAK key combinations receive special handling by console processes. I was running some python scripts and was unable to stop some with CTRL + C, but CTRL + BREAK worked every time.


I had this issue with Windows 10 Pro Build 18363 and Python 3.8.1.
