comparison mercurial/ui.py @ 16367:c14898df3b92 stable

ui: swallow EBADF on stderr ui.write_err already swallows EPIPE and EIO if a write to stderr fails. On Mac OS X at least, a write to a closed file descriptor results in EBADF. Before this patch, hg would exit with status 1 if a write to stderr failed during startup (e.g. while trying to print a warning about not finding an extension): $ ./hg --config extensions.foo= version 2>&-; echo $? 1 With this patch, it correctly swallows stderr and continues to run the command: $ ./hg --config extensions.foo= version 2>&- Mercurial Distributed SCM (version 2.1) ...
author Kevin Bullock <kbullock@ringworld.org>
date Wed, 04 Apr 2012 12:46:54 -0500
parents 69e792cf7851
children 329887a7074c
comparison
equal deleted inserted replaced
16364:f64b25f147d7 16367:c14898df3b92
478 # stderr may be buffered under win32 when redirected to files, 478 # stderr may be buffered under win32 when redirected to files,
479 # including stdout. 479 # including stdout.
480 if not getattr(self.ferr, 'closed', False): 480 if not getattr(self.ferr, 'closed', False):
481 self.ferr.flush() 481 self.ferr.flush()
482 except IOError, inst: 482 except IOError, inst:
483 if inst.errno not in (errno.EPIPE, errno.EIO): 483 if inst.errno not in (errno.EPIPE, errno.EIO, errno.EBADF):
484 raise 484 raise
485 485
486 def flush(self): 486 def flush(self):
487 try: self.fout.flush() 487 try: self.fout.flush()
488 except: pass 488 except: pass