Message297286
> interrupt_main is now equivalent to the user having hit control-C.
That's true on a POSIX system with pthread_kill, but not really for a Windows process that's attached to a console.
A real Ctrl+C executes the registered control handlers for the process. To emulate this, PyErr_SetInterrupt could try calling GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0) to broadcast a Ctrl+C event. If the latter fails, it can fall back on raise(SIGINT), such as when the process isn't attached to a console.
One problem is that GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0) doesn't cancel a blocking console read like Ctrl+C does. Python's C handler could call CancelSynchronousIo(hMainThread) to address this problem in general. Unfortunately, when a console read is canceled in the client, it isn't canceled in the console itself. The contents of the read will be discarded, but it's a bit clunky that the user has to press enter. |
|
Date |
User |
Action |
Args |
2017-06-29 17:21:47 | eryksun | set | recipients:
+ eryksun, terry.reedy, njs, martin.panter, Mark, louielu |
2017-06-29 17:21:47 | eryksun | set | messageid: <1498756907.1.0.443822251284.issue29926@psf.upfronthosting.co.za> |
2017-06-29 17:21:47 | eryksun | link | issue29926 messages |
2017-06-29 17:21:46 | eryksun | create | |
|