]> granicus.if.org Git - icinga2/commitdiff
Fix crash when daemonizing Icinga
authorGunnar Beutner <gunnar.beutner@netways.de>
Wed, 12 Nov 2014 11:44:14 +0000 (12:44 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Wed, 12 Nov 2014 11:44:14 +0000 (12:44 +0100)
refs #7648

lib/base/application.cpp
lib/cli/daemoncommand.cpp

index fe6512185fd45cadc70b11386730ace2cecdeca3..786cda166854dcc918600d342af3bf09de714fdc 100644 (file)
@@ -223,7 +223,7 @@ void Application::SetResourceLimits(void)
 
                if (!new_argv) {
                        perror("malloc");
-                       exit(1);
+                       Exit(EXIT_FAILURE);
                }
 
                new_argv[0] = argv[0];
@@ -242,7 +242,7 @@ void Application::SetResourceLimits(void)
                if (execvp(new_argv[0], new_argv) < 0)
                        perror("execvp");
 
-               exit(1);
+               Exit(EXIT_FAILURE);
        }
 #      else /* RLIMIT_STACK */
        Log(LogNotice, "Application", "System does not support adjusting the resource limit for stack size (RLIMIT_STACK)");
index 3a58e38d6966f88e10f54b9f2a25d48b7c820ab7..c2aed84fa8f2a0f1ade21b7bf74bea660c8e7a5e 100644 (file)
@@ -190,14 +190,14 @@ static bool Daemonize(void)
 
                if (ret == pid) {
                        Log(LogCritical, "cli", "The daemon could not be started. See log output for details.");
-                       exit(EXIT_FAILURE);
+                       Application::Exit(EXIT_FAILURE);
                } else if (ret == -1) {
                        Log(LogCritical, "cli")
                            << "waitpid() failed with error code " << errno << ", \"" << Utility::FormatErrorNumber(errno) << "\"";
-                       exit(EXIT_FAILURE);
+                       Application::Exit(EXIT_FAILURE);
                }
 
-               exit(0);
+               Application::Exit(0);
        }
 #endif /* _WIN32 */