mirror of https://github.com/Icinga/icinga2.git
parent
9ae9204df2
commit
37e075c38a
|
@ -614,6 +614,25 @@ int main(int argc, char **argv)
|
|||
/* must be called before using any other libbase functions */
|
||||
Application::InitializeBase();
|
||||
|
||||
#ifndef _WIN32
|
||||
rlimit rl;
|
||||
if (getrlimit(RLIMIT_NOFILE, &rl) >= 0) {
|
||||
rlim_t maxfds = rl.rlim_max;
|
||||
|
||||
if (maxfds == RLIM_INFINITY)
|
||||
maxfds = 65536;
|
||||
|
||||
for (rlim_t i = 3; i < maxfds; i++) {
|
||||
int rc = close(i);
|
||||
|
||||
#ifdef I2_DEBUG
|
||||
if (rc >= 0)
|
||||
std::cerr << "Closed FD " << i << " which we inherited from our parent process." << std::endl;
|
||||
#endif /* I2_DEBUG */
|
||||
}
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/* Set command-line arguments. */
|
||||
Application::SetArgC(argc);
|
||||
Application::SetArgV(argv);
|
||||
|
|
|
@ -120,23 +120,6 @@ void Application::Exit(int rc)
|
|||
|
||||
void Application::InitializeBase(void)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
rlimit rl;
|
||||
if (getrlimit(RLIMIT_NOFILE, &rl) >= 0) {
|
||||
rlim_t maxfds = rl.rlim_max;
|
||||
|
||||
if (maxfds == RLIM_INFINITY)
|
||||
maxfds = 65536;
|
||||
|
||||
for (rlim_t i = 3; i < maxfds; i++) {
|
||||
#ifdef I2_DEBUG
|
||||
if (close(i) >= 0)
|
||||
std::cerr << "Closed FD " << i << " which we inherited from our parent process." << std::endl;
|
||||
#endif /* I2_DEBUG */
|
||||
}
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#ifdef _WIN32
|
||||
/* disable GUI-based error messages for LoadLibrary() */
|
||||
SetErrorMode(SEM_FAILCRITICALERRORS);
|
||||
|
|
Loading…
Reference in New Issue