This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients Mark, eryksun, louielu, martin.panter, njs, terry.reedy
Date 2017-06-29.17:21:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1498756907.1.0.443822251284.issue29926@psf.upfronthosting.co.za>
In-reply-to
Content
> 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.
History
Date User Action Args
2017-06-29 17:21:47eryksunsetrecipients: + eryksun, terry.reedy, njs, martin.panter, Mark, louielu
2017-06-29 17:21:47eryksunsetmessageid: <1498756907.1.0.443822251284.issue29926@psf.upfronthosting.co.za>
2017-06-29 17:21:47eryksunlinkissue29926 messages
2017-06-29 17:21:46eryksuncreate