]> granicus.if.org Git - icinga2/commitdiff
Move some of the initialization code into icinga-app
authorGunnar Beutner <gunnar@beutner.name>
Fri, 20 Feb 2015 18:57:26 +0000 (19:57 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Fri, 20 Feb 2015 18:57:26 +0000 (19:57 +0100)
refs #6257

icinga-app/icinga.cpp
lib/base/application.cpp

index d842a06faf2456311a58a312f63c4f24bbf93b91..0e16bee91908dc0432cee954abeeb77de804c098 100644 (file)
@@ -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);
index c2171599227d5eee9183463ffdb06001ddc5efed..205f175a4922d41e233bb08bb9c1fadfa69aacdf 100644 (file)
@@ -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);