Mercurial > hg > mercurial-source
diff mercurial/commandserver.py @ 30370:591c3badff2e stable
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.
author | Jun Wu <quark@fb.com> |
---|---|
date | Mon, 18 Jul 2016 15:59:08 +0100 (2016-07-18) |
parents | 1bb94666b9fc |
children | 7f2313450e86 |
line wrap: on
line diff
--- a/mercurial/commandserver.py +++ b/mercurial/commandserver.py @@ -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.