From 9f6d3787559febb48611b1477eaa6a35beadf71a Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 27 Feb 2024 10:05:32 +0000 Subject: [PATCH] Fix write_pidfile on Windows. Microsoft's documentation lies again. --- src/init.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index b974f7cdd..be896ad63 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -221,7 +221,11 @@ static void write_pidfile() std::ofstream stream(pidfile.str()); if (!stream.is_open()) throw CoreException("Can not write to PID file " + pidfile); - stream << getpid() << std::endl; +#ifdef _WIN32 + stream << GetCurrentProcessId() << std::endl; +#else + stream << getpid() << std::endl; +#endif atexit(remove_pidfile); }