Close the fds after log initialisation.

This commit is contained in:
Jonathan Naylor 2018-07-26 20:43:27 +01:00
parent 0bf5ee565c
commit e281095a79
2 changed files with 16 additions and 8 deletions

View File

@ -127,10 +127,6 @@ void CNXDNGateway::run()
return;
}
::close(STDIN_FILENO);
::close(STDOUT_FILENO);
::close(STDERR_FILENO);
// If we are currently root...
if (getuid() == 0) {
struct passwd* user = ::getpwnam("mmdvm");
@ -168,6 +164,14 @@ void CNXDNGateway::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

@ -120,10 +120,6 @@ void CNXDNReflector::run()
return;
}
::close(STDIN_FILENO);
::close(STDOUT_FILENO);
::close(STDERR_FILENO);
// If we are currently root...
if (getuid() == 0) {
struct passwd* user = ::getpwnam("mmdvm");
@ -161,6 +157,14 @@ void CNXDNReflector::run()
return;
}
#if !defined(_WIN32) && !defined(_WIN64)
if (m_daemon) {
::close(STDIN_FILENO);
::close(STDOUT_FILENO);
::close(STDERR_FILENO);
}
#endif
unsigned short tg = m_conf.getTG();
CNXDNNetwork nxdnNetwork(m_conf.getNetworkPort(), m_conf.getNetworkDebug());