Nathaniel's suggestion to update the implementation to work with raise(SIGINT) sounds like a good idea.
Fpr Windows, GenerateConsoleCtrlEvent is definitely a non-starter. PyErr_SetInterrupt shouldn't depend on having an attached console. IDLE generally runs without one. Even if the process has a console, there's no way to limit GenerateConsoleCtrlEvent to just the current process. It works with process groups, like POSIX killpg(). Typically a process is created in the session's Winlogon process group unless a new group was created by calling CreateProcess with the flag CREATE_NEW_PROCESS_GROUP. If you call GenerateConsoleCtrlEvent on a process ID that's not a group ID, the console behaves as if you passed group ID 0, which broadcasts to all processes attached to the console. |