X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/703ad5b9a14dc2a42849669d3618a8ba1136bb92..8ea089c181fa66c80f3ad8f933fca1c96a7ba4ae:/stglibs/scriptexecuter.lib/scriptexecuter.c?ds=sidebyside diff --git a/stglibs/scriptexecuter.lib/scriptexecuter.c b/stglibs/scriptexecuter.lib/scriptexecuter.c index 462d310b..bdf60230 100644 --- a/stglibs/scriptexecuter.lib/scriptexecuter.c +++ b/stglibs/scriptexecuter.lib/scriptexecuter.c @@ -40,27 +40,28 @@ if (msgsnd(msgid, (void *)&sd, MAX_SCRIPT_LEN, 0) < 0) return 0; } //----------------------------------------------------------------------------- -#ifdef LINUX +#if defined(LINUX) || defined(DARWIN) void Executer(int msgID, pid_t pid, char * procName) #else void Executer(int msgID, pid_t pid) #endif { +struct SCRIPT_DATA sd; +struct sigaction newsa, oldsa; +sigset_t sigmask; + msgid = msgID; if (pid) return; nonstop = 1; -#ifdef LINUX +#if defined(LINUX) || defined(DARWIN) memset(procName, 0, strlen(procName)); strcpy(procName, "stg-exec"); #else setproctitle("stg-exec"); #endif -struct sigaction newsa, oldsa; -sigset_t sigmask; - sigemptyset(&sigmask); sigaddset(&sigmask, SIGTERM); newsa.sa_handler = SIG_IGN; @@ -89,21 +90,17 @@ newsa.sa_mask = sigmask; newsa.sa_flags = 0; sigaction(SIGUSR1, &newsa, &oldsa); -int ret; - -struct SCRIPT_DATA sd; - while (nonstop) { sd.mtype = 1; - ret = msgrcv(msgid, &sd, MAX_SCRIPT_LEN, 0, 0); + int ret = msgrcv(msgid, &sd, MAX_SCRIPT_LEN, 0, 0); if (ret < 0) { usleep(20000); continue; } - int ret = system(sd.script); + ret = system(sd.script); if (ret == -1) { // Fork failed