# HG changeset patch # User Yuya Nishihara # Date 2018-09-19 14:11:07 # Node ID 7cdd47d9ccf8c9f75433efc1ec35932274651b02 # Parent a93fe297dfb3f017ce9f9e252d980ed750433b80 chgserver: restore pager fds attached within runcommand session While rewriting chg in Rust, I noticed the server leaks the client's pager fd. This isn't a problem right now since the IPC process terminates earlier than the pager, but I believe the fds attached within a "runcommand" request should be released as soon as the session ends. diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py --- a/mercurial/chgserver.py +++ b/mercurial/chgserver.py @@ -456,7 +456,16 @@ class chgcmdserver(commandserver.server) os.umask(mask) def runcommand(self): - return super(chgcmdserver, self).runcommand() + # pager may be attached within the runcommand session, which should + # be detached at the end of the session. otherwise the pager wouldn't + # receive EOF. + globaloldios = self._oldios + self._oldios = [] + try: + return super(chgcmdserver, self).runcommand() + finally: + self._restoreio() + self._oldios = globaloldios def setenv(self): """Clear and update os.environ