check for interrupt from fgets on Windows

Windows does not have the error EINTR when a blocking syscall is
interrupted by a signal. The ReadFile API that fgets is implemented
with instead use ERROR_OPERATION_ABORTED. Check for that after fgets.

llvm-svn: 366520
This commit is contained in:
Nathan Lanza 2019-07-19 00:40:37 +00:00
parent bb0896970a
commit cb30520555
1 changed files with 3 additions and 0 deletions

View File

@ -383,6 +383,9 @@ bool IOHandlerEditline::GetLine(std::string &line, bool &interrupted) {
// fgets twice until this bug is fixed.
if (fgets(buffer, sizeof(buffer), in) == nullptr &&
fgets(buffer, sizeof(buffer), in) == nullptr) {
// this is the equivalent of EINTR for Windows
if (GetLastError() == ERROR_OPERATION_ABORTED)
continue;
#else
if (fgets(buffer, sizeof(buffer), in) == nullptr) {
#endif