]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Get rid of InspIRCd::QuickExit.
authorPeter Powell <petpow@saberuk.com>
Sun, 10 Dec 2017 13:48:57 +0000 (13:48 +0000)
committerPeter Powell <petpow@saberuk.com>
Sat, 23 Dec 2017 12:13:06 +0000 (12:13 +0000)
This is just a thin wrapper around exit(). I don't think we really
need it.

While we are changing this code the setgroup/setuser code should be
using EXIT_STATUS_CONFIG too.

include/inspircd.h
src/inspircd.cpp
src/socketengine.cpp

index 7e9007a1dc3687061ba0c4b02b35e4c047f1393f..40c368106260f92dffddeec2113e6cbf610ac418 100644 (file)
@@ -402,11 +402,6 @@ class CoreExport InspIRCd
         */
        void Exit(int status);
 
-       /** Causes the server to exit immediately with exit code 0.
-        * The status code is required for signal handlers, and ignored.
-        */
-       static void QuickExit(int status);
-
        /** Formats the input string with the specified arguments.
        * @param formatString The string to format
        * @param ... A variable number of format arguments.
index 8c5137d3b426d187bfeaa3a285f443836d816912..a671c3d7b2872602a5b50b2e7f28ca843769765c 100644 (file)
@@ -132,15 +132,10 @@ void InspIRCd::SetSignals()
        signal(SIGTERM, InspIRCd::SetSignal);
 }
 
-void InspIRCd::QuickExit(int status)
-{
-       exit(status);
-}
-
 // Required for returning the proper value of EXIT_SUCCESS for the parent process
 static void VoidSignalHandler(int signalreceived)
 {
-       exit(0);
+       exit(EXIT_STATUS_NOERROR);
 }
 
 bool InspIRCd::DaemonSeed()
@@ -149,7 +144,7 @@ bool InspIRCd::DaemonSeed()
        std::cout << "InspIRCd Process ID: " << con_green << GetCurrentProcessId() << con_reset << std::endl;
        return true;
 #else
-       // Do not use QuickExit here: It will exit with status SIGTERM which would break e.g. daemon scripts
+       // Do not use exit() here: It will exit with status SIGTERM which would break e.g. daemon scripts
        signal(SIGTERM, VoidSignalHandler);
 
        int childpid = fork();
@@ -166,7 +161,7 @@ bool InspIRCd::DaemonSeed()
                 */
                while (kill(childpid, 0) != -1)
                        sleep(1);
-               exit(0);
+               exit(EXIT_STATUS_NOERROR);
        }
        setsid ();
        std::cout << "InspIRCd Process ID: " << con_green << getpid() << con_reset << std::endl;
@@ -503,20 +498,20 @@ InspIRCd::InspIRCd(int argc, char** argv) :
                if (setgroups(0, NULL) == -1)
                {
                        this->Logs->Log("STARTUP", LOG_DEFAULT, "setgroups() failed (wtf?): %s", strerror(errno));
-                       this->QuickExit(0);
+                       exit(EXIT_STATUS_CONFIG);
                }
 
                struct group* g = getgrnam(SetGroup.c_str());
                if (!g)
                {
                        this->Logs->Log("STARTUP", LOG_DEFAULT, "getgrnam(%s) failed (wrong group?): %s", SetGroup.c_str(), strerror(errno));
-                       this->QuickExit(0);
+                       exit(EXIT_STATUS_CONFIG);
                }
 
                if (setgid(g->gr_gid) == -1)
                {
                        this->Logs->Log("STARTUP", LOG_DEFAULT, "setgid(%d) failed (wrong group?): %s", g->gr_gid, strerror(errno));
-                       this->QuickExit(0);
+                       exit(EXIT_STATUS_CONFIG);
                }
        }
 
@@ -528,13 +523,13 @@ InspIRCd::InspIRCd(int argc, char** argv) :
                if (!u)
                {
                        this->Logs->Log("STARTUP", LOG_DEFAULT, "getpwnam(%s) failed (wrong user?): %s", SetUser.c_str(), strerror(errno));
-                       this->QuickExit(0);
+                       exit(EXIT_STATUS_CONFIG);
                }
 
                if (setuid(u->pw_uid) == -1)
                {
                        this->Logs->Log("STARTUP", LOG_DEFAULT, "setuid(%d) failed (wrong user?): %s", u->pw_uid, strerror(errno));
-                       this->QuickExit(0);
+                       exit(EXIT_STATUS_CONFIG);
                }
        }
 
index 58e15af4444bcc936fc353ed164687c3e0ed947f..986726f3aaf58da79080fe4fcee051c670b4fce3 100644 (file)
@@ -66,7 +66,7 @@ void EventHandler::OnEventHandlerError(int errornum)
 void SocketEngine::InitError()
 {
        std::cerr << con_red << "FATAL ERROR!" << con_reset << " Socket engine initialization failed. " << strerror(errno) << '.' << std::endl;
-       ServerInstance->QuickExit(EXIT_STATUS_SOCKETENGINE);
+       exit(EXIT_STATUS_SOCKETENGINE);
 }
 
 void SocketEngine::LookupMaxFds()