diff hgext/chgserver.py @ 28014:83fc0c055664

chgserver: create new process group after fork (issue5051) This is to make SIGTSTP work. Before the patch, the server process group is considered "orphaned" and will ignore SIGTSTP, SIGTTIN, SIGTTOU, according to POSIX. See the comment above `will_become_orphaned_pgrp` in `kernel/exit.c` from Linux 4.3 for details. SIGTSTP is important if chgserver runs some ncurses commend like `commit -i`. Ncurses has its own SIGTSTP handler which will do the following: 1. Clean the screen 2. Stop itself by resending SIGTSTP to itself 3. Restore the screen If SIGTSTP is ignored, step 2 will be a noop, which means the process cannot be suspended properly. In order to make things work, chg client needs to forward SIGTSTP and SIGCONT to server as well.
author Jun Wu <quark@fb.com>
date Tue, 19 Jan 2016 18:20:13 +0000
parents 8c9bbf5cd349
children 7cc57a531f0c
line wrap: on
line diff
--- a/hgext/chgserver.py	Fri Feb 05 16:54:01 2016 -0600
+++ b/hgext/chgserver.py	Tue Jan 19 18:20:13 2016 +0000
@@ -354,6 +354,10 @@
 # copied from mercurial/commandserver.py
 class _requesthandler(SocketServer.StreamRequestHandler):
     def handle(self):
+        # use a different process group from the master process, making this
+        # process pass kernel "is_current_pgrp_orphaned" check so signals like
+        # SIGTSTP, SIGTTIN, SIGTTOU are not ignored.
+        os.setpgid(0, 0)
         ui = self.server.ui
         repo = self.server.repo
         sv = chgcmdserver(ui, repo, self.rfile, self.wfile, self.connection)