##// END OF EJS Templates
windows: fix incorrect detection of broken pipe when writing to pager...
Sune Foldager -
r38575:3a0f322a stable
parent child Browse files
Show More
@@ -44,6 +44,7 b' from . import ('
44 _ERROR_INVALID_PARAMETER = 87
44 _ERROR_INVALID_PARAMETER = 87
45 _ERROR_BROKEN_PIPE = 109
45 _ERROR_BROKEN_PIPE = 109
46 _ERROR_INSUFFICIENT_BUFFER = 122
46 _ERROR_INSUFFICIENT_BUFFER = 122
47 _ERROR_NO_DATA = 232
47
48
48 # WPARAM is defined as UINT_PTR (unsigned type)
49 # WPARAM is defined as UINT_PTR (unsigned type)
49 # LPARAM is defined as LONG_PTR (signed type)
50 # LPARAM is defined as LONG_PTR (signed type)
@@ -406,6 +407,12 b' def peekpipe(pipe):'
406
407
407 return avail.value
408 return avail.value
408
409
410 def lasterrorwaspipeerror(err):
411 if err.errno != errno.EINVAL:
412 return False
413 err = _kernel32.GetLastError()
414 return err == _ERROR_BROKEN_PIPE or err == _ERROR_NO_DATA
415
409 def testpid(pid):
416 def testpid(pid):
410 '''return True if pid is still running or unable to
417 '''return True if pid is still running or unable to
411 determine, False otherwise'''
418 determine, False otherwise'''
@@ -172,7 +172,7 b' class winstdout(object):'
172 self.fp.write(s[start:end])
172 self.fp.write(s[start:end])
173 start = end
173 start = end
174 except IOError as inst:
174 except IOError as inst:
175 if inst.errno != 0:
175 if inst.errno != 0 and not win32.lasterrorwaspipeerror(inst):
176 raise
176 raise
177 self.close()
177 self.close()
178 raise IOError(errno.EPIPE, 'Broken pipe')
178 raise IOError(errno.EPIPE, 'Broken pipe')
@@ -181,7 +181,7 b' class winstdout(object):'
181 try:
181 try:
182 return self.fp.flush()
182 return self.fp.flush()
183 except IOError as inst:
183 except IOError as inst:
184 if inst.errno != errno.EINVAL:
184 if not win32.lasterrorwaspipeerror(inst):
185 raise
185 raise
186 raise IOError(errno.EPIPE, 'Broken pipe')
186 raise IOError(errno.EPIPE, 'Broken pipe')
187
187
General Comments 0
You need to be logged in to leave comments. Login now