Skip to contentSkip to conversation

oeqa: modernise subprocess: preexec_fn=os.setsid -> start_new_session=True

PATCH New André Draszik 1 participant 2 messages Feb 3, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 oeqa: modernise subprocess: preexec_fn=os.setsid -> start_new_session=True

start_new_session was added to python3 subprocess in v3.2 and is meant to take the place of the common use of preexec_fn to call os.setsid() in the child - as done here.

Update to use the new equivalent.

---
 meta/lib/oeqa/controllers/masterimage.py | 2 +-
 meta/lib/oeqa/core/target/ssh.py         | 2 +-
 meta/lib/oeqa/utils/sshcontrol.py        | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
meta/lib/oeqa/controllers/masterimage.py +1 -1
index 0435dfa125..0bf5917e48 100644
@@ -97,7 +97,7 @@ class MasterImageHardwareTarget(oeqa.targetcontrol.BaseTarget, metaclass=ABCMeta
         if self.powercontrol_cmd:
             cmd = "%s %s" % (self.powercontrol_cmd, msg)
             try:
-                commands.runCmd(cmd, assert_error=False, preexec_fn=os.setsid, env=self.origenv)
+                commands.runCmd(cmd, assert_error=False, start_new_session=True, env=self.origenv)
             except CommandError as e:
                 bb.fatal(str(e))
 
meta/lib/oeqa/core/target/ssh.py +1 -1
index 63fc9468b3..090b40a814 100644
@@ -247,7 +247,7 @@ def SSHCall(command, logger, timeout=None, **opts):
         "stdin": None,
         "shell": False,
         "bufsize": -1,
-        "preexec_fn": os.setsid,
+        "start_new_session": True,
     }
     options.update(opts)
     output = ''
meta/lib/oeqa/utils/sshcontrol.py +1 -1
index 49a07264c6..36c2ecb3db 100644
@@ -23,7 +23,7 @@ class SSHProcess(object):
             "stdin": None,
             "shell": False,
             "bufsize": -1,
-            "preexec_fn": os.setsid,
+            "start_new_session": True,
         }
         self.options = dict(self.defaultopts)
         self.options.update(options)
Signature · 1 line
2.23.0.rc1
#1 lore raw

PATCH 2/2 rt-tests: modernise subprocess: preexec_fn=os.setsid -> start_new_session=True

start_new_session was added to python3 subprocess in v3.2 and is meant to take the place of the common use of preexec_fn to call os.setsid() in the child - as done here.

Update to use the new equivalent.

---
 meta/recipes-rt/rt-tests/files/rt_bmark.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/recipes-rt/rt-tests/files/rt_bmark.py +2 -2
index 57b39b52a1..3b84447a0f 100755
@@ -166,12 +166,12 @@ def start_stress(*args):
         log("  Command: '", stress_cmd_str, "'")
         log()
 
-        # preexec_fn=os.setsid causes stress to be executed in a separate
+        # start_new_session causes stress to be executed in a separate
         # session, => it gets a new process group (incl. children). It
         # can then be terminated using os.killpg in end_stress without
         # terminating this script.
 
-        p = subprocess.Popen(stress_cmd, preexec_fn=os.setsid)
+        p = subprocess.Popen(stress_cmd, start_new_session=True)
 
         return p
 
Signature · 1 line
2.23.0.rc1