# HG changeset patch # User Kevin Bullock # Date 1333561614 18000 # Node ID c14898df3b927ff5e0189866534190f85981823f # Parent f64b25f147d7091fcc34a0f9f0ac6f5c704c2f1f 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) ... diff -r f64b25f147d7 -r c14898df3b92 mercurial/ui.py --- a/mercurial/ui.py Thu Apr 05 12:31:21 2012 +0100 +++ b/mercurial/ui.py Wed Apr 04 12:46:54 2012 -0500 @@ -480,7 +480,7 @@ if not getattr(self.ferr, 'closed', False): self.ferr.flush() except IOError, inst: - if inst.errno not in (errno.EPIPE, errno.EIO): + if inst.errno not in (errno.EPIPE, errno.EIO, errno.EBADF): raise def flush(self):