diff options
author | Max Kellermann <max@duempel.org> | 2014-01-18 12:01:09 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-01-18 12:42:30 +0100 |
commit | be47320a0589a84eb942790c3884bb6e25c38a2f (patch) | |
tree | be474aac8c82dfdd9d00b8893a1c4f11caecb6c1 /src/PidFile.hxx | |
parent | 9f3ce7551a481f757feeb6837961f565a686c945 (diff) | |
download | mpd-be47320a0589a84eb942790c3884bb6e25c38a2f.tar.gz mpd-be47320a0589a84eb942790c3884bb6e25c38a2f.tar.xz mpd-be47320a0589a84eb942790c3884bb6e25c38a2f.zip |
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.
Diffstat (limited to 'src/PidFile.hxx')
-rw-r--r-- | src/PidFile.hxx | 19 |
1 files changed, 19 insertions, 0 deletions
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; |