comparison mercurial/commandserver.py @ 29609: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
parents 1bb94666b9fc
children 7f2313450e86
comparison
equal deleted inserted replaced
29608:681fe090d82e 29609:591c3badff2e
341 finally: 341 finally:
342 sv.cleanup() 342 sv.cleanup()
343 _restoreio(ui, fin, fout) 343 _restoreio(ui, fin, fout)
344 344
345 def _initworkerprocess(): 345 def _initworkerprocess():
346 # use a different process group from the master process, making this 346 # use a different process group from the master process, in order to:
347 # process pass kernel "is_current_pgrp_orphaned" check so signals like 347 # 1. make the current process group no longer "orphaned" (because the
348 # SIGTSTP, SIGTTIN, SIGTTOU are not ignored. 348 # parent of this process is in a different process group while
349 # remains in a same session)
350 # according to POSIX 2.2.2.52, orphaned process group will ignore
351 # terminal-generated stop signals like SIGTSTP (Ctrl+Z), which will
352 # cause trouble for things like ncurses.
353 # 2. the client can use kill(-pgid, sig) to simulate terminal-generated
354 # SIGINT (Ctrl+C) and process-exit-generated SIGHUP. our child
355 # processes like ssh will be killed properly, without affecting
356 # unrelated processes.
349 os.setpgid(0, 0) 357 os.setpgid(0, 0)
350 # change random state otherwise forked request handlers would have a 358 # change random state otherwise forked request handlers would have a
351 # same state inherited from parent. 359 # same state inherited from parent.
352 random.seed() 360 random.seed()
353 361