From d7f422f02976b8d48cce533f9292400f2f85a141 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Thu, 21 Mar 2024 10:50:44 +0100 Subject: improved process monitoring behaviour with invalid pids (#16) --- src/zenutil/zenserverprocess.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/zenutil/zenserverprocess.cpp') 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; } -- cgit v1.2.3