summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/osmo_gsm_tester/process.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/osmo_gsm_tester/process.py b/src/osmo_gsm_tester/process.py
index 66ecae5..4b22d0c 100644
--- a/src/osmo_gsm_tester/process.py
+++ b/src/osmo_gsm_tester/process.py
@@ -157,16 +157,27 @@ class Process(log.Origin):
return f
def launch(self):
+ preexec_fn = None
log.dbg('cd %r; %s %s' % (
os.path.abspath(str(self.run_dir)),
' '.join(['%s=%r'%(k,v) for k,v in self.popen_kwargs.get('env', {}).items()]),
' '.join(self.popen_args)))
+ if self.popen_args[0] == "sudo":
+ # sudo drops forwarding of signals sent by processes of the same
+ # process group, which means by default will drop signals from
+ # parent and children processes. By moving it to another group, we
+ # will later be able to kill it.
+ # Note: sudo documentation is wrong, since it states it only drops
+ # signals from children.
+ preexec_fn = os.setpgrp
+
self.process_obj = subprocess.Popen(
self.popen_args,
stdout=self.make_output_log('stdout'),
stderr=self.make_output_log('stderr'),
stdin=subprocess.PIPE,
+ preexec_fn=preexec_fn,
shell=False,
cwd=self.run_dir.path,
**self.popen_kwargs)