From 6e65ce5e18ebbe9350c90984e7bc6bcf73011889 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Thu, 26 Jul 2018 18:47:55 +0100 Subject: [PATCH] Close the fds as the log initialisation. --- DMRGateway.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/DMRGateway.cpp b/DMRGateway.cpp index 2fee5b8..2b161e5 100644 --- a/DMRGateway.cpp +++ b/DMRGateway.cpp @@ -238,10 +238,6 @@ int CDMRGateway::run() return -1; } - ::close(STDIN_FILENO); - ::close(STDOUT_FILENO); - ::close(STDERR_FILENO); - // If we are currently root... if (getuid() == 0) { struct passwd* user = ::getpwnam("mmdvm"); @@ -279,6 +275,14 @@ int CDMRGateway::run() return 1; } +#if !defined(_WIN32) && !defined(_WIN64) + if (m_daemon) { + ::close(STDIN_FILENO); + ::close(STDOUT_FILENO); + ::close(STDERR_FILENO); + } +#endif + LogInfo(HEADER1); LogInfo(HEADER2); LogInfo(HEADER3);