X-Git-Url: http://git.pk910.de/?p=NeonServV5.git;a=blobdiff_plain;f=src%2Fsignal.c;h=175f61150db18ba33863ba979eef4d3953be9eef;hp=8886e6f471eaa11f360b4b51bbe0b42fbf9e03c8;hb=291f15058a67b95bdfe6f6861cdfcb8ffd626149;hpb=acf398714c6bdac0c794884842164e0651b6e942 diff --git a/src/signal.c b/src/signal.c index 8886e6f..175f611 100644 --- a/src/signal.c +++ b/src/signal.c @@ -1,4 +1,4 @@ -/* signal.c - NeonServ v5.4 +/* signal.c - NeonServ v5.5 * Copyright (C) 2011-2012 Philipp Kreil (pk910) * * This program is free software: you can redistribute it and/or modify @@ -18,6 +18,7 @@ #include "bots.h" #include "ChanNode.h" #include "ClientSocket.h" +#include "IOHandler.h" #include "ConfigParser.h" static void sigcrash(); @@ -48,7 +49,8 @@ void sighandler(int signum) { } static void sigcrash(int signum) { - char *coregen = ""; + char coregen[MAXLEN]; + coregen[0] = 0; char *signame; switch(signum) { case SIGSEGV: @@ -68,8 +70,8 @@ static void sigcrash(int signum) { #ifndef WIN32 char gcore[50]; sprintf(gcore, "gcore %u", getpid()); - system(gcore); //generate core file - coregen = "core file generated."; + int sysretn = system(gcore); //generate core file + sprintf(coregen, "core file generated. (%d)", sysretn); putlog(LOGLEVEL_ERROR | LOGLEVEL_INFO, "generated core file.\n"); #endif char *alertchan = get_string_field("General.alertchan"); @@ -84,15 +86,17 @@ static void sigcrash(int signum) { struct ClientSocket *bot; for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) { if((bot->flags & SOCKET_FLAG_CONNECTED)) { - close(bot->sock); - bot->flags &= SOCKET_FLAG_CONNECTED; + iohandler_close(bot->iofd); + bot->flags &= ~(SOCKET_FLAG_CONNECTED | SOCKET_FLAG_READY); + bot->iofd = NULL; } } putlog(LOGLEVEL_INFO, "hard shutdown...\n"); exit_daemon(); - usleep(1000000); + usleep(2000000); //hard restart restart_process(); + exit(0); } static void sigexit(int signum) {