From be47320a0589a84eb942790c3884bb6e25c38a2f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 18 Jan 2014 12:01:09 +0100 Subject: Daemon: fork as early as possible Keep the parent process around until MPD has finished initializing. This is important for libraries that are allergic to fork(), such as libupnp. --- src/PidFile.hxx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/PidFile.hxx') diff --git a/src/PidFile.hxx b/src/PidFile.hxx index c06ed6b61..a242c7810 100644 --- a/src/PidFile.hxx +++ b/src/PidFile.hxx @@ -47,6 +47,25 @@ public: PidFile(const PidFile &) = delete; + void Close() { + if (file == nullptr) + return; + + fclose(file); + } + + void Delete(const AllocatedPath &path) { + if (file == nullptr) { + assert(path.IsNull()); + return; + } + + assert(!path.IsNull()); + + fclose(file); + RemoveFile(path); + } + void Write(pid_t pid) { if (file == nullptr) return; -- cgit v1.2.3