Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[tesh] setsid -> setpgid(0,0)
authorMillian Poquet <millian.poquet@inria.fr>
Thu, 13 Jun 2019 17:52:34 +0000 (19:52 +0200)
committerMillian Poquet <millian.poquet@inria.fr>
Thu, 13 Jun 2019 17:52:34 +0000 (19:52 +0200)
As the cleanup function is based on process groups and not session ids,
creating a process group rather than a session seems more adequate.

Info: http://www.andy-pearce.com/blog/posts/2013/Aug/process-groups-and-sessions/

tools/tesh/tesh.py

index 91084a9..8e20c88 100755 (executable)
@@ -327,6 +327,9 @@ class Cmd(object):
         global pgtokill
 
         try:
+            preexec_function = None
+            if not isWindows():
+                preexec_function = lambda: os.setpgid(0, 0)
             proc = subprocess.Popen(
                 args,
                 bufsize=1,
@@ -334,7 +337,7 @@ class Cmd(object):
                 stdout=subprocess.PIPE,
                 stderr=subprocess.STDOUT,
                 universal_newlines=True,
-                start_new_session=True)
+                preexec_fn=preexec_function)
             try:
                 if not isWindows():
                     pgtokill = os.getpgid(proc.pid)