Close the fds as the log initialisation.

This commit is contained in:
Jonathan Naylor 2018-07-26 18:47:55 +01:00
parent b92c08ecaf
commit 6e65ce5e18
1 changed files with 8 additions and 4 deletions

View File

@ -238,10 +238,6 @@ int CDMRGateway::run()
return -1; return -1;
} }
::close(STDIN_FILENO);
::close(STDOUT_FILENO);
::close(STDERR_FILENO);
// If we are currently root... // If we are currently root...
if (getuid() == 0) { if (getuid() == 0) {
struct passwd* user = ::getpwnam("mmdvm"); struct passwd* user = ::getpwnam("mmdvm");
@ -279,6 +275,14 @@ int CDMRGateway::run()
return 1; return 1;
} }
#if !defined(_WIN32) && !defined(_WIN64)
if (m_daemon) {
::close(STDIN_FILENO);
::close(STDOUT_FILENO);
::close(STDERR_FILENO);
}
#endif
LogInfo(HEADER1); LogInfo(HEADER1);
LogInfo(HEADER2); LogInfo(HEADER2);
LogInfo(HEADER3); LogInfo(HEADER3);