From 971aa39e10cbaff75a68d6f26b5e553fdf1cbe4f Mon Sep 17 00:00:00 2001 From: psychon Date: Mon, 25 Aug 2008 14:42:11 +0000 Subject: [PATCH] Don't start a new process for starting znc after --makeconf The code now just falls through to the normal bootup code. Thanks to kroimon for this idea and also for writing this patch. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1171 726aef4b-f618-498e-8847-2d620e286838 --- main.cpp | 39 ++++----------------------------------- 1 file changed, 4 insertions(+), 35 deletions(-) diff --git a/main.cpp b/main.cpp index 05030ef7..4020dae7 100644 --- a/main.cpp +++ b/main.cpp @@ -158,42 +158,11 @@ int main(int argc, char** argv) { } if (bMakeConf) { - if (pZNC->WriteNewConfig(sConfig)) { - char const* args[5]; - - if (argc > 2) { - args[0] = argv[0]; - if (!sDataDir.empty()) { - args[1] = "--datadir"; - args[2] = strdup(sDataDir.c_str()); - args[3] = argv[optind]; - args[4] = NULL; - } else { - args[1] = argv[optind]; - args[2] = NULL; - } - } else if (argc > 1) { - args[0] = argv[0]; - if (!sDataDir.empty()) { - args[1] = "--datadir"; - args[2] = strdup(sDataDir.c_str()); - args[3] = NULL; - } else { - args[1] = NULL; - } - } else { - CUtils::PrintError("Unable to launch znc [Try manually restarting]"); - return 1; - } - - if ((chdir(pZNC->GetCurPath().c_str()) == -1) - || (execv(*argv, (char *const*)args) == -1)) { - CUtils::PrintError("Unable to launch znc [" + CString(strerror(errno)) + "]"); - return 1; - } + if (!pZNC->WriteNewConfig(sConfig)) { + delete pZNC; + return 0; } - - return 0; + /* Fall through to normal bootup */ } if (!pZNC->ParseConfig(sConfig)) {