merge with stable
authorAugie Fackler <augie@google.com>
Mon, 09 Jul 2018 09:50:23 -0400
changeset 38601 af8d8513d7de
parent 38600 a936d1368fc5 (current diff)
parent 38533 3a0f322af192 (diff)
child 38602 44f5acfb9ad2
merge with stable
mercurial/windows.py
--- a/mercurial/win32.py	Fri Jul 06 17:57:46 2018 +0200
+++ b/mercurial/win32.py	Mon Jul 09 09:50:23 2018 -0400
@@ -44,6 +44,7 @@
 _ERROR_INVALID_PARAMETER = 87
 _ERROR_BROKEN_PIPE = 109
 _ERROR_INSUFFICIENT_BUFFER = 122
+_ERROR_NO_DATA = 232
 
 # WPARAM is defined as UINT_PTR (unsigned type)
 # LPARAM is defined as LONG_PTR (signed type)
@@ -406,6 +407,12 @@
 
     return avail.value
 
+def lasterrorwaspipeerror(err):
+    if err.errno != errno.EINVAL:
+        return False
+    err = _kernel32.GetLastError()
+    return err == _ERROR_BROKEN_PIPE or err == _ERROR_NO_DATA
+
 def testpid(pid):
     '''return True if pid is still running or unable to
     determine, False otherwise'''
--- a/mercurial/windows.py	Fri Jul 06 17:57:46 2018 +0200
+++ b/mercurial/windows.py	Mon Jul 09 09:50:23 2018 -0400
@@ -173,7 +173,7 @@
                 self.fp.write(s[start:end])
                 start = end
         except IOError as inst:
-            if inst.errno != 0:
+            if inst.errno != 0 and not win32.lasterrorwaspipeerror(inst):
                 raise
             self.close()
             raise IOError(errno.EPIPE, 'Broken pipe')
@@ -182,7 +182,7 @@
         try:
             return self.fp.flush()
         except IOError as inst:
-            if inst.errno != errno.EINVAL:
+            if not win32.lasterrorwaspipeerror(inst):
                 raise
             raise IOError(errno.EPIPE, 'Broken pipe')