1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
19 #include "inspircd_config.h"
21 #include "inspircd_io.h"
25 #include <ext/hash_map>
43 #include "inspstring.h"
45 #include "helperfuncs.h"
47 #include "socketengine.h"
49 #include "command_parse.h"
50 #include "cmd_restart.h"
52 extern ServerConfig* Config;
53 extern InspIRCd* ServerInstance;
55 extern std::vector<Module*> modules;
56 extern std::vector<ircd_module*> factory;
58 extern user_hash clientlist;
59 extern chan_hash chanlist;
60 extern whowas_hash whowas;
61 extern std::vector<userrec*> all_opers;
62 extern std::vector<userrec*> local_users;
63 extern userrec* fd_ref_table[65536];
65 void cmd_restart::Handle (char **parameters, int pcnt, userrec *user)
68 log(DEFAULT,"Restart: %s",user->nick);
69 if (!strcmp(parameters[0],Config->restartpass))
71 WriteOpers("*** RESTART command from %s!%s@%s, restarting server.",user->nick,user->ident,user->host);
73 argv[0] = Config->MyExecutable;
85 // close ALL file descriptors
86 send_error("Server restarting.");
88 for (int i = 0; i < 65536; i++)
95 execv(Config->MyExecutable,argv);
101 WriteOpers("*** Failed RESTART Command from %s!%s@%s.",user->nick,user->ident,user->host);