Close the fds after log initialisation.

This commit is contained in:
Jonathan Naylor 2018-07-26 20:23:42 +01:00
parent aba8d436ea
commit 12c9336374
2 changed files with 16 additions and 8 deletions

View File

@ -119,10 +119,6 @@ void CP25Gateway::run()
return;
}
::close(STDIN_FILENO);
::close(STDOUT_FILENO);
::close(STDERR_FILENO);
// If we are currently root...
if (getuid() == 0) {
struct passwd* user = ::getpwnam("mmdvm");
@ -160,6 +156,14 @@ void CP25Gateway::run()
return;
}
#if !defined(_WIN32) && !defined(_WIN64)
if (m_daemon) {
::close(STDIN_FILENO);
::close(STDOUT_FILENO);
::close(STDERR_FILENO);
}
#endif
in_addr rptAddr = CUDPSocket::lookup(m_conf.getRptAddress());
unsigned int rptPort = m_conf.getRptPort();

View File

@ -119,10 +119,6 @@ void CP25Reflector::run()
return;
}
::close(STDIN_FILENO);
::close(STDOUT_FILENO);
::close(STDERR_FILENO);
// If we are currently root...
if (getuid() == 0) {
struct passwd* user = ::getpwnam("mmdvm");
@ -160,6 +156,14 @@ void CP25Reflector::run()
return;
}
#if !defined(_WIN32) && !defined(_WIN64)
if (m_daemon) {
::close(STDIN_FILENO);
::close(STDOUT_FILENO);
::close(STDERR_FILENO);
}
#endif
CNetwork network(m_conf.getNetworkPort(), m_conf.getNetworkDebug());
ret = network.open();