[Lldb-commits] [PATCH] D83815: [lldb/Test] Use a process group for subprocesses
Jonas Devlieghere via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Jul 14 14:34:40 PDT 2020
JDevlieghere created this revision.
JDevlieghere added reviewers: labath, teemperor.
Herald added a subscriber: abidh.
Use a process group for processes spawned by the test suite so we can send a signal to the whole group. This ensures any child processes are terminated as well.
Repository:
rLLDB LLDB
https://reviews.llvm.org/D83815
Files:
lldb/packages/Python/lldbsuite/test/lldbtest.py
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -428,6 +428,7 @@
stdout=PIPE,
stderr=PIPE,
shell=True,
+ preexec_fn=os.setsid,
**kwargs)
pid = process.pid
this_output, this_error = process.communicate()
@@ -889,13 +890,16 @@
def cleanupSubprocesses(self):
# Ensure any subprocesses are cleaned up
for p in self.subprocesses:
- p.terminate()
+ try:
+ os.kill(os.getpgid(p.pid), signal.SIGTERM)
+ except OSError:
+ pass
del p
del self.subprocesses[:]
# Ensure any forked processes are cleaned up
for pid in self.forkedProcessPids:
try:
- os.kill(pid, signal.SIGTERM)
+ os.kill(os.getpgid(pid), signal.SIGTERM)
except OSError:
pass
del self.forkedProcessPids[:]
@@ -921,6 +925,7 @@
os.dup2(fd, 2)
# This call causes the child to have its of group ID
os.setpgid(0, 0)
+ os.setsid()
os.execvp(executable, [executable] + args)
# Give the child time to get through the execvp() call
time.sleep(0.1)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83815.277977.patch
Type: text/x-patch
Size: 1444 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200714/d3991e30/attachment.bin>
More information about the lldb-commits
mailing list