X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/0fd1cedaf374bd51b529f30a333a47547326d8b9..24dbb9a02319b9f1e231315c8391cf7609453973:/projects/stargazer/main.cpp?ds=sidebyside diff --git a/projects/stargazer/main.cpp b/projects/stargazer/main.cpp index 7e83b72d..3a987715 100644 --- a/projects/stargazer/main.cpp +++ b/projects/stargazer/main.cpp @@ -46,9 +46,7 @@ #include "stg/plugin.h" #include "stg/logger.h" #include "stg/scriptexecuter.h" -#include "stg/conffiles.h" #include "stg/version.h" -#include "stg/pinger.h" #include "stg_timer.h" #include "settings_impl.h" #include "users_impl.h" @@ -72,7 +70,6 @@ using namespace std; #define START_FILE "/._ST_ART_ED_" set executersPid; -static pid_t stgChildPid; //----------------------------------------------------------------------------- bool StartModCmp(const PLUGIN_RUNNER & lhs, const PLUGIN_RUNNER & rhs) @@ -143,12 +140,20 @@ switch (executerPid) case 0: delete settings; +#ifdef LINUX Executer(*msgID, executerPid, procName); +#else + Executer(*msgID, executerPid); +#endif return 1; default: if (executersPid.empty()) { +#ifdef LINUX Executer(*msgID, executerPid, NULL); +#else + Executer(*msgID, executerPid); +#endif } executersPid.insert(executerPid); } @@ -162,11 +167,11 @@ int ForkAndWait(const string &) #endif { #ifndef NO_DAEMON -stgChildPid = fork(); +pid_t childPid = fork(); string startFile = confDir + START_FILE; unlink(startFile.c_str()); -switch (stgChildPid) +switch (childPid) { case -1: return -1; @@ -287,6 +292,10 @@ for (size_t i = 0; i < settings->GetExecutersNum(); i++) PIDFile pidFile(settings->GetPIDFileName()); +sigset_t signalSet; +sigfillset(&signalSet); +pthread_sigmask(SIG_BLOCK, &signalSet, NULL); + StartTimer(); WaitTimer(); if (!IsStgTimerRunning()) @@ -396,7 +405,6 @@ creat(startFile.c_str(), S_IRUSR); while (true) { - sigset_t signalSet; sigfillset(&signalSet); int sig = 0; sigwait(&signalSet, &sig);