mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 19:00:54 -06:00
cmUVProcessChain: Add Detached option for spawning daemons
This commit is contained in:
@@ -156,6 +156,12 @@ cmUVProcessChainBuilder& cmUVProcessChainBuilder::SetWorkingDirectory(
|
||||
return *this;
|
||||
}
|
||||
|
||||
cmUVProcessChainBuilder& cmUVProcessChainBuilder::SetDetached()
|
||||
{
|
||||
this->Detached = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
uv_loop_t* cmUVProcessChainBuilder::GetLoop() const
|
||||
{
|
||||
return this->Loop;
|
||||
@@ -337,6 +343,9 @@ void cmUVProcessChain::InternalData::SpawnProcess(
|
||||
arguments.push_back(nullptr);
|
||||
options.args = const_cast<char**>(arguments.data());
|
||||
options.flags = UV_PROCESS_WINDOWS_HIDE;
|
||||
if (this->Builder->Detached) {
|
||||
options.flags |= UV_PROCESS_DETACHED;
|
||||
}
|
||||
#if UV_VERSION_MAJOR > 1 || \
|
||||
(UV_VERSION_MAJOR == 1 && UV_VERSION_MINOR >= 48) || \
|
||||
!defined(CMAKE_USE_SYSTEM_LIBUV)
|
||||
@@ -380,6 +389,9 @@ void cmUVProcessChain::InternalData::SpawnProcess(
|
||||
process.Process.spawn(*this->Loop, options, &process)) < 0) {
|
||||
process.Finish();
|
||||
}
|
||||
if (this->Builder->Detached) {
|
||||
uv_unref((uv_handle_t*)process.Process);
|
||||
}
|
||||
process.InputPipe.reset();
|
||||
process.OutputPipe.reset();
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
cmUVProcessChainBuilder& SetExternalStream(Stream stdio, int fd);
|
||||
cmUVProcessChainBuilder& SetExternalStream(Stream stdio, FILE* stream);
|
||||
cmUVProcessChainBuilder& SetWorkingDirectory(std::string dir);
|
||||
cmUVProcessChainBuilder& SetDetached();
|
||||
|
||||
uv_loop_t* GetLoop() const;
|
||||
|
||||
@@ -69,6 +70,7 @@ private:
|
||||
std::vector<ProcessConfiguration> Processes;
|
||||
std::string WorkingDirectory;
|
||||
bool MergedBuiltinStreams = false;
|
||||
bool Detached = false;
|
||||
uv_loop_t* Loop = nullptr;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user