commandserver: update comment about setpgid stable
authorJun Wu <quark@fb.com>
Mon, 18 Jul 2016 15:59:08 +0100
branchstable
changeset 29609 591c3badff2e
parent 29608 681fe090d82e
child 29610 754f63671229
commandserver: update comment about setpgid Now setpgid has 2 main purposes: better handling for terminal-generated SIGTSTP, SIGINT, and process-exit-generated SIGHUP. Update the comment to explain things more clearly.
mercurial/commandserver.py
--- a/mercurial/commandserver.py	Sun Jul 17 22:55:47 2016 +0100
+++ b/mercurial/commandserver.py	Mon Jul 18 15:59:08 2016 +0100
@@ -343,9 +343,17 @@
             _restoreio(ui, fin, fout)
 
 def _initworkerprocess():
-    # 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.
+    # use a different process group from the master process, in order to:
+    # 1. make the current process group no longer "orphaned" (because the
+    #    parent of this process is in a different process group while
+    #    remains in a same session)
+    #    according to POSIX 2.2.2.52, orphaned process group will ignore
+    #    terminal-generated stop signals like SIGTSTP (Ctrl+Z), which will
+    #    cause trouble for things like ncurses.
+    # 2. the client can use kill(-pgid, sig) to simulate terminal-generated
+    #    SIGINT (Ctrl+C) and process-exit-generated SIGHUP. our child
+    #    processes like ssh will be killed properly, without affecting
+    #    unrelated processes.
     os.setpgid(0, 0)
     # change random state otherwise forked request handlers would have a
     # same state inherited from parent.