diff options
| author | Stefan Boberg <[email protected]> | 2024-03-21 10:50:44 +0100 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-03-21 10:50:44 +0100 |
| commit | d7f422f02976b8d48cce533f9292400f2f85a141 (patch) | |
| tree | 74032ff63b5308ef6012526959ebd0fcde7ff4ba /src/zenutil/zenserverprocess.cpp | |
| parent | 5.4.2-pre5 (diff) | |
| download | zen-d7f422f02976b8d48cce533f9292400f2f85a141.tar.xz zen-d7f422f02976b8d48cce533f9292400f2f85a141.zip | |
improved process monitoring behaviour with invalid pids (#16)
Diffstat (limited to 'src/zenutil/zenserverprocess.cpp')
| -rw-r--r-- | src/zenutil/zenserverprocess.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/zenutil/zenserverprocess.cpp b/src/zenutil/zenserverprocess.cpp index 0b0127f93..3667ad2c6 100644 --- a/src/zenutil/zenserverprocess.cpp +++ b/src/zenutil/zenserverprocess.cpp @@ -673,7 +673,14 @@ ZenServerInstance::AttachToRunningServer(int BasePort) throw std::runtime_error("No server found"); } - m_Process.Initialize(Entry->Pid); + std::error_code Ec; + m_Process.Initialize(Entry->Pid, Ec); + + if (Ec) + { + throw std::system_error(Ec, fmt::format("failed to attach to running server on port {} using pid {}", BasePort, Entry->Pid.load())); + } + CreateShutdownEvent(Entry->EffectiveListenPort); m_BasePort = Entry->EffectiveListenPort; } |