-/* main.c - NeonServ v5.3
+/* main.c - NeonServ v5.4
* Copyright (C) 2011-2012 Philipp Kreil (pk910)
*
* This program is free software: you can redistribute it and/or modify
socket_wait = time(0) + SOCKET_SELECT_TIME;
do {
if(!socket_loop(SOCKET_SELECT_TIME)) {
- putlog(LOGLEVEL_ERROR, "No more active Bots... shutting down.");
+ if(!running) break;
+ putlog(LOGLEVEL_ERROR, "No more active Bots... shutting down.\n");
cleanup();
exit(0);
}
} while(time(0) < socket_wait);
+ if(!running) break;
clearTempUsers();
destroyEvents();
mysql_free();
#endif
void exit_daemon() {
+ running = 0;
if(daemonized) {
remove(PID_FILE);
}
break;
}
}
+ #ifndef WIN32
if(geteuid() == 0 || getuid() == 0) {
fprintf(stderr, "NeonServ may not be run with super user privileges.\n");
exit(0);
}
+ #endif
+ #ifdef ENABLE_MEMORY_DEBUG
+ initMemoryDebug();
+ #endif
if(!loadConfig(CONF_FILE)) {
fprintf(stderr, "Unable to load " CONF_FILE "\n");
exit(0);
atexit(exit_daemon);
FILE *pidfile = fopen(PID_FILE, "w");
if (pidfile == NULL) {
- fprintf(stderr, "Unable to create PID file: %s", strerror(errno));
- putlog(LOGLEVEL_ERROR, "Unable to create PID file: %s", strerror(errno));
+ fprintf(stderr, "Unable to create PID file: %s\n", strerror(errno));
+ putlog(LOGLEVEL_ERROR, "Unable to create PID file: %s\n", strerror(errno));
} else {
fprintf(pidfile, "%i\n", (int)getpid());
fclose(pidfile);
signal(SIGSEGV, sighandler);
signal(SIGTERM, sighandler);
- #ifdef ENABLE_MEMORY_DEBUG
- initMemoryDebug();
- #endif
-
start_time = time(0);
#ifdef WIN32
socket_wait = time(0) + SOCKET_SELECT_TIME;
do {
if(!socket_loop(SOCKET_SELECT_TIME)) {
- putlog(LOGLEVEL_ERROR, "No more active Bots... shutting down.");
+ putlog(LOGLEVEL_ERROR, "No more active Bots... shutting down.\n");
cleanup();
exit(0);
}