diff --git a/Misc/NEWS.d/next/Windows/2018-07-19-16-37-47.bpo-28166.bBdWo8.rst b/Misc/NEWS.d/next/Windows/2018-07-19-16-37-47.bpo-28166.bBdWo8.rst new file mode 100644 index 00000000000000..75b5128de4a765 --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2018-07-19-16-37-47.bpo-28166.bBdWo8.rst @@ -0,0 +1 @@ +Continue reading when SIGINT is ignored. diff --git a/Modules/_io/winconsoleio.c b/Modules/_io/winconsoleio.c index f08406643f0323..b7b1f8cf813f59 100644 --- a/Modules/_io/winconsoleio.c +++ b/Modules/_io/winconsoleio.c @@ -574,14 +574,16 @@ read_console_w(HANDLE handle, DWORD maxlen, DWORD *readlen) { break; err = 0; HANDLE hInterruptEvent = _PyOS_SigintEvent(); - if (WaitForSingleObjectEx(hInterruptEvent, 100, FALSE) - == WAIT_OBJECT_0) { + DWORD state = WaitForSingleObjectEx(hInterruptEvent, 100, FALSE); + if (state == WAIT_OBJECT_0 || state == WAIT_TIMEOUT) { ResetEvent(hInterruptEvent); Py_BLOCK_THREADS sig = PyErr_CheckSignals(); Py_UNBLOCK_THREADS if (sig < 0) break; + else + continue; } } *readlen += n; diff --git a/Parser/myreadline.c b/Parser/myreadline.c index edb291a6691a78..55c96736bc3e35 100644 --- a/Parser/myreadline.c +++ b/Parser/myreadline.c @@ -131,15 +131,17 @@ _PyOS_WindowsConsoleReadline(HANDLE hStdIn) goto exit; err = 0; HANDLE hInterruptEvent = _PyOS_SigintEvent(); - if (WaitForSingleObjectEx(hInterruptEvent, 100, FALSE) - == WAIT_OBJECT_0) { - ResetEvent(hInterruptEvent); - PyEval_RestoreThread(_PyOS_ReadlineTState); - s = PyErr_CheckSignals(); - PyEval_SaveThread(); - if (s < 0) - goto exit; - } + DWORD state = WaitForSingleObjectEx(hInterruptEvent, 100, FALSE); + if (state == WAIT_OBJECT_0 || state == WAIT_TIMEOUT) { + ResetEvent(hInterruptEvent); + PyEval_RestoreThread(_PyOS_ReadlineTState); + s = PyErr_CheckSignals(); + PyEval_SaveThread(); + if (s < 0) + goto exit; + else + continue; + } break; }