From 37e075c38a76b07e4bb4a2f217f19c62f2233d2e Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 20 Feb 2015 19:57:26 +0100 Subject: [PATCH] Move some of the initialization code into icinga-app refs #6257 --- icinga-app/icinga.cpp | 19 +++++++++++++++++++ lib/base/application.cpp | 17 ----------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/icinga-app/icinga.cpp b/icinga-app/icinga.cpp index d842a06fa..0e16bee91 100644 --- a/icinga-app/icinga.cpp +++ b/icinga-app/icinga.cpp @@ -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); diff --git a/lib/base/application.cpp b/lib/base/application.cpp index c21715992..205f175a4 100644 --- a/lib/base/application.cpp +++ b/lib/base/application.cpp @@ -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); -- 2.49.0