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 William.Schwartz
Recipients William.Schwartz, eryksun, ncoghlan, paul.moore, steve.dower, tim.golden, zach.ware
Date 2021-01-18.23:41:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1611013279.04.0.681567313054.issue42962@roundup.psfhosted.org>
In-reply-to
Content
> In Windows, os.kill() is a rather confused function.

I know how it feels.

To be honest, I don't have an opinion about whether the steps I laid out ought to work. I just reported it because the SystemError indicates that a C-API function was returning non-NULL even after PyErr_Occurred() returns true. I think that's what you're referring to here...

> it doesn't clear the error that was set as a result of the GenerateConsoleCtrlEvent() call, which causes SystemError to be raised.

...but I lost you on where that's happening and why. Frankly, Windows IPC is not in my wheelhouse.

>>  Oddly, `echo %errorlevel%` will print `0` rather than `-1073741510` 
>
> There's nothing odd about that.

Here's why I thought it was odd. The following session is from the Windows Command shell inside *Command Prompt* (not Windows Terminal):

 C:\Users\wksch>python --version
 Python 3.9.1
 C:\Users\wksch>python -c"import os, signal, time; os.kill(os.getpid(), signal.CTRL_C_EVENT); time.sleep(1)"
 Traceback (most recent call last):
   File "<string>", line 1, in <module>
 KeyboardInterrupt
 ^C
 C:\Users\wksch>echo %errorlevel%
 -1073741510

In the Windows Command shell inside *Windows Terminal* (not Command Prompt):

 C:\Users\wksch>python -c"import os, signal, time; os.kill(os.getpid(), signal.CTRL_C_EVENT); time.sleep(1)"

 C:\Users\wksch>echo %errorlevel%
 0

 C:\Users\wksch>python -c"raise KeyboardInterrupt"
 Traceback (most recent call last):
   File "<string>", line 1, in <module>
 KeyboardInterrupt
 ^C
 C:\Users\wksch>echo %errorlevel%
 -1073741510
History
Date User Action Args
2021-01-18 23:41:19William.Schwartzsetrecipients: + William.Schwartz, paul.moore, ncoghlan, tim.golden, zach.ware, eryksun, steve.dower
2021-01-18 23:41:19William.Schwartzsetmessageid: <1611013279.04.0.681567313054.issue42962@roundup.psfhosted.org>
2021-01-18 23:41:19William.Schwartzlinkissue42962 messages
2021-01-18 23:41:18William.Schwartzcreate