Mercurial > hg-stable
diff mercurial/hook.py @ 45737:b3e8d8e4a40d
hook: ignore EPIPE when flushing stdout/stderr
This fixes the bug described in the parent commit.
test-transaction-rollback-on-sigpipe.t is updated to show the new
behavior.
Differential Revision: https://phab.mercurial-scm.org/D9152
author | Mitchell Plamann <mplamann@janestreet.com> |
---|---|
date | Mon, 05 Oct 2020 17:18:39 -0400 |
parents | fd3b94f1712d |
children | 89a2afe31e82 |
line wrap: on
line diff
--- a/mercurial/hook.py Mon Oct 05 13:23:16 2020 -0400 +++ b/mercurial/hook.py Mon Oct 05 17:18:39 2020 -0400 @@ -8,6 +8,7 @@ from __future__ import absolute_import import contextlib +import errno import os import sys @@ -289,10 +290,18 @@ # The stderr is fully buffered on Windows when connected to a pipe. # A forcible flush is required to make small stderr data in the # remote side available to the client immediately. - procutil.stderr.flush() + try: + procutil.stderr.flush() + except IOError as err: + if err.errno not in (errno.EPIPE, errno.EIO, errno.EBADF): + raise error.StdioError(err) if _redirect and oldstdout >= 0: - procutil.stdout.flush() # write hook output to stderr fd + try: + procutil.stdout.flush() # write hook output to stderr fd + except IOError as err: + if err.errno not in (errno.EPIPE, errno.EIO, errno.EBADF): + raise error.StdioError(err) os.dup2(oldstdout, stdoutno) os.close(oldstdout)