changeset 39739:7cdd47d9ccf8

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.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 19 Sep 2018 23:11:07 +0900
parents a93fe297dfb3
children e0a7cfa9323f
files mercurial/chgserver.py
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/chgserver.py	Wed Sep 19 22:57:47 2018 +0900
+++ b/mercurial/chgserver.py	Wed Sep 19 23:11:07 2018 +0900
@@ -456,7 +456,16 @@
         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