diff options
Diffstat (limited to '')
-rw-r--r-- | src/unix/Daemon.cxx | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/src/unix/Daemon.cxx b/src/unix/Daemon.cxx index d283108ed..9aa16a078 100644 --- a/src/unix/Daemon.cxx +++ b/src/unix/Daemon.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -36,6 +36,10 @@ #include <grp.h> #endif +#ifndef WCOREDUMP +#define WCOREDUMP(v) 0 +#endif + #ifndef WIN32 /** the Unix user name which MPD runs as */ @@ -62,28 +66,17 @@ static int detach_fd = -1; void daemonize_kill(void) { - FILE *fp; - int pid, ret; - if (pidfile.IsNull()) FatalError("no pid_file specified in the config file"); - fp = FOpen(pidfile, "r"); - if (fp == nullptr) { - const std::string utf8 = pidfile.ToUTF8(); - FormatFatalSystemError("Unable to open pid file \"%s\"", - utf8.c_str()); - } - - if (fscanf(fp, "%i", &pid) != 1) { + const pid_t pid = ReadPidFile(pidfile); + if (pid < 0) { const std::string utf8 = pidfile.ToUTF8(); FormatFatalError("unable to read the pid from file \"%s\"", utf8.c_str()); } - fclose(fp); - ret = kill(pid, SIGTERM); - if (ret < 0) + if (kill(pid, SIGTERM) < 0) FormatFatalSystemError("unable to kill process %i", int(pid)); |