mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 15:44:11 +02:00
Fix writing the PID file if there is no previous PID file.
This commit is contained in:
parent
2a09a722c8
commit
98f7515eee
@ -462,15 +462,12 @@ void Application::UpdatePidFile(const String& filename)
|
|||||||
if (m_PidFile != NULL)
|
if (m_PidFile != NULL)
|
||||||
fclose(m_PidFile);
|
fclose(m_PidFile);
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
const char *mode = "r+";
|
|
||||||
#else /* _WIN32 */
|
|
||||||
const char *mode = "w";
|
|
||||||
#endif /* _WIN32 */
|
|
||||||
|
|
||||||
/* There's just no sane way of getting a file descriptor for a
|
/* There's just no sane way of getting a file descriptor for a
|
||||||
* C++ ofstream which is why we're using FILEs here. */
|
* C++ ofstream which is why we're using FILEs here. */
|
||||||
m_PidFile = fopen(filename.CStr(), mode);
|
m_PidFile = fopen(filename.CStr(), "r+");
|
||||||
|
|
||||||
|
if (m_PidFile == NULL)
|
||||||
|
m_PidFile = fopen(filename.CStr(), "w");
|
||||||
|
|
||||||
if (m_PidFile == NULL)
|
if (m_PidFile == NULL)
|
||||||
BOOST_THROW_EXCEPTION(runtime_error("Could not open PID file '" + filename + "'"));
|
BOOST_THROW_EXCEPTION(runtime_error("Could not open PID file '" + filename + "'"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user