From 8754c50d230b218a8edc335a7ec47ce23285c73f Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Sat, 10 Jun 2023 14:30:29 +0200 Subject: [PATCH] Do not ignore write return value #36 --- BaseCommon/Daemon.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/BaseCommon/Daemon.cpp b/BaseCommon/Daemon.cpp index aa34ed7..4c4b193 100644 --- a/BaseCommon/Daemon.cpp +++ b/BaseCommon/Daemon.cpp @@ -169,7 +169,11 @@ DAEMONIZE_RESULT CDaemon::daemonise(const std::string& pidFile, const std::strin char str[256]; sprintf(str, "%d\n", getpid()); /* Write PID to lockfile */ - write(m_pid_fd, str, strlen(str)); + ssize_t writeCount = write(m_pid_fd, str, strlen(str)); + if(writeCount < 0) { + CLog::logFatal("Failed to write to PID File. Err: %d", errno); + return DR_FAILURE; + } } return DR_CHILD;