diff options
author | Brad King <brad.king@kitware.com> | 2024-01-22 19:55:47 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-01-24 22:10:00 (GMT) |
commit | bcbb212df704d36736731aa567b291fd97401804 (patch) | |
tree | 6fef8b57dd7aa10c9f15447b18dc74951de68dad /Source/CTest/cmCTestVC.cxx | |
parent | adb3e13d323aeb19c3824112cfa712cc122db3b4 (diff) | |
download | CMake-bcbb212df704d36736731aa567b291fd97401804.zip CMake-bcbb212df704d36736731aa567b291fd97401804.tar.gz CMake-bcbb212df704d36736731aa567b291fd97401804.tar.bz2 |
Revert use of libuv for process execution for 3.28
Wide use of CMake 3.28.{1,0[-rcN]} has uncovered some hangs and crashes
in libuv SIGCHLD handling on some platforms, particularly in virtualization
environments on macOS hosts. Although the bug does not seem to be in CMake,
we can restore stability in the CMake 3.28 release series for users of such
platforms by reverting our new uses of libuv for process execution.
Revert implementation changes merged by commit 4771544386 (Merge topic
'replace-cmsysprocess-with-cmuvprocesschain', 2023-09-06, v3.28.0-rc1~138),
but keep test suite updates.
Issue: #25414, #25500, #25562, #25589
Diffstat (limited to 'Source/CTest/cmCTestVC.cxx')
-rw-r--r-- | Source/CTest/cmCTestVC.cxx | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx index cbbb5a5..609ccba 100644 --- a/Source/CTest/cmCTestVC.cxx +++ b/Source/CTest/cmCTestVC.cxx @@ -7,9 +7,10 @@ #include <sstream> #include <vector> +#include "cmsys/Process.h" + #include "cmCTest.h" #include "cmSystemTools.h" -#include "cmUVProcessChain.h" #include "cmValue.h" #include "cmXMLWriter.h" @@ -54,12 +55,18 @@ bool cmCTestVC::InitialCheckout(const std::string& command) // Construct the initial checkout command line. std::vector<std::string> args = cmSystemTools::ParseArguments(command); + std::vector<char const*> vc_co; + vc_co.reserve(args.size() + 1); + for (std::string const& arg : args) { + vc_co.push_back(arg.c_str()); + } + vc_co.push_back(nullptr); // Run the initial checkout command and log its output. this->Log << "--- Begin Initial Checkout ---\n"; OutputLogger out(this->Log, "co-out> "); OutputLogger err(this->Log, "co-err> "); - bool result = this->RunChild(args, &out, &err, parent); + bool result = this->RunChild(vc_co.data(), &out, &err, parent.c_str()); this->Log << "--- End Initial Checkout ---\n"; if (!result) { cmCTestLog(this->CTest, ERROR_MESSAGE, @@ -68,35 +75,35 @@ bool cmCTestVC::InitialCheckout(const std::string& command) return result; } -bool cmCTestVC::RunChild(const std::vector<std::string>& cmd, - OutputParser* out, OutputParser* err, - std::string workDir, Encoding encoding) +bool cmCTestVC::RunChild(char const* const* cmd, OutputParser* out, + OutputParser* err, const char* workDir, + Encoding encoding) { this->Log << cmCTestVC::ComputeCommandLine(cmd) << "\n"; - cmUVProcessChainBuilder builder; - if (workDir.empty()) { - workDir = this->SourceDirectory; - } - builder.AddCommand(cmd).SetWorkingDirectory(workDir); - auto status = cmCTestVC::RunProcess(builder, out, err, encoding); - return status.front().SpawnResult == 0 && status.front().ExitStatus == 0; + cmsysProcess* cp = cmsysProcess_New(); + cmsysProcess_SetCommand(cp, cmd); + workDir = workDir ? workDir : this->SourceDirectory.c_str(); + cmsysProcess_SetWorkingDirectory(cp, workDir); + cmCTestVC::RunProcess(cp, out, err, encoding); + int result = cmsysProcess_GetExitValue(cp); + cmsysProcess_Delete(cp); + return result == 0; } -std::string cmCTestVC::ComputeCommandLine(const std::vector<std::string>& cmd) +std::string cmCTestVC::ComputeCommandLine(char const* const* cmd) { std::ostringstream line; const char* sep = ""; - for (auto const& arg : cmd) { - line << sep << "\"" << arg << "\""; + for (const char* const* arg = cmd; *arg; ++arg) { + line << sep << "\"" << *arg << "\""; sep = " "; } return line.str(); } -bool cmCTestVC::RunUpdateCommand(const std::vector<std::string>& cmd, - OutputParser* out, OutputParser* err, - Encoding encoding) +bool cmCTestVC::RunUpdateCommand(char const* const* cmd, OutputParser* out, + OutputParser* err, Encoding encoding) { // Report the command line. this->UpdateCommandLine = this->ComputeCommandLine(cmd); @@ -106,7 +113,7 @@ bool cmCTestVC::RunUpdateCommand(const std::vector<std::string>& cmd, } // Run the command. - return this->RunChild(cmd, out, err, "", encoding); + return this->RunChild(cmd, out, err, nullptr, encoding); } std::string cmCTestVC::GetNightlyTime() |