comparison mercurial/chgserver.py @ 39755: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 a9f56e4501c1
comparison
equal deleted inserted replaced
39754:a93fe297dfb3 39755:7cdd47d9ccf8
454 mask = struct.unpack('>I', self._read(4))[0] 454 mask = struct.unpack('>I', self._read(4))[0]
455 _log('setumask %r\n' % mask) 455 _log('setumask %r\n' % mask)
456 os.umask(mask) 456 os.umask(mask)
457 457
458 def runcommand(self): 458 def runcommand(self):
459 return super(chgcmdserver, self).runcommand() 459 # pager may be attached within the runcommand session, which should
460 # be detached at the end of the session. otherwise the pager wouldn't
461 # receive EOF.
462 globaloldios = self._oldios
463 self._oldios = []
464 try:
465 return super(chgcmdserver, self).runcommand()
466 finally:
467 self._restoreio()
468 self._oldios = globaloldios
460 469
461 def setenv(self): 470 def setenv(self):
462 """Clear and update os.environ 471 """Clear and update os.environ
463 472
464 Note that not all variables can make an effect on the running process. 473 Note that not all variables can make an effect on the running process.