aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/main.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2024-08-22 10:58:02 +0200
committerGitHub Enterprise <[email protected]>2024-08-22 10:58:02 +0200
commit57b56f20894a982bbc37e7784f7d0159bece5d5b (patch)
tree4585303413b42f159c99ffde932d8f2fb058fdee /src/zenserver/main.cpp
parentif a zenserver is already using our named mutex - exit with error code instea... (diff)
downloadzen-57b56f20894a982bbc37e7784f7d0159bece5d5b.tar.xz
zen-57b56f20894a982bbc37e7784f7d0159bece5d5b.zip
safer calls to IsProcessRunning (#131)
* safer calls to IsProcessRunning to handle cases where we can't check status of processes
Diffstat (limited to 'src/zenserver/main.cpp')
-rw-r--r--src/zenserver/main.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/zenserver/main.cpp b/src/zenserver/main.cpp
index 93516f5fd..25a5d5cf5 100644
--- a/src/zenserver/main.cpp
+++ b/src/zenserver/main.cpp
@@ -109,12 +109,27 @@ ZenEntryPoint::Run()
{
if (m_ServerOptions.OwnerPid)
{
- if (!IsProcessRunning(m_ServerOptions.OwnerPid))
+ std::error_code Ec;
+ if (!IsProcessRunning(m_ServerOptions.OwnerPid, Ec))
{
- ZEN_WARN("Sponsor owner pid {} is no longer running, will not add sponsor to process listening to port {} (pid: {})",
- m_ServerOptions.OwnerPid,
- m_ServerOptions.BasePort,
- Entry->Pid.load());
+ if (Ec)
+ {
+ ZEN_WARN(
+ "Sponsor owner pid {} can not be checked for running state, reason: '{}'. Will not add sponsor to process "
+ "listening to port {} (pid: {})",
+ m_ServerOptions.OwnerPid,
+ Ec.message(),
+ m_ServerOptions.BasePort,
+ Entry->Pid.load());
+ }
+ else
+ {
+ ZEN_WARN(
+ "Sponsor owner pid {} is no longer running, will not add sponsor to process listening to port {} (pid: {})",
+ m_ServerOptions.OwnerPid,
+ m_ServerOptions.BasePort,
+ Entry->Pid.load());
+ }
std::exit(1);
}
ZEN_INFO(