From b526d79eafbe59b37673ce3ac4217770ad8c6af4 Mon Sep 17 00:00:00 2001 From: Martchus Date: Sun, 28 Jan 2024 21:55:13 +0100 Subject: [PATCH] Always use a process group in helper for involing test applications So far only the implementation using Boost.Process was using a process group; with this change also the implementation using POSIX APIs uses a process group. This way the code can wait until all sub processes have terminated. --- tests/testutils.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/testutils.cpp b/tests/testutils.cpp index 0eba6a9..b6bb6e9 100644 --- a/tests/testutils.cpp +++ b/tests/testutils.cpp @@ -542,6 +542,7 @@ static int execAppInternal(const char *appPath, const char *const *args, std::st // get return code int childReturnCode; waitpid(child, &childReturnCode, 0); + waitpid(-child, nullptr, 0); return childReturnCode; } else { // child process @@ -553,6 +554,12 @@ static int execAppInternal(const char *appPath, const char *const *args, std::st close(readCerrPipe); close(writeCerrPipe); + // -> create process group + if (setpgid(0, 0)) { + cerr << Phrases::Error << "Unable create process group: " << std::strerror(errno) << Phrases::EndFlush; + exit(EXIT_FAILURE); + } + // -> modify environment variable LLVM_PROFILE_FILE to apply new path for profiling output if (!newProfilingPath.empty()) { setenv("LLVM_PROFILE_FILE", newProfilingPath.data(), true);