11 #include "stg/scriptexecuter.h"
13 #define MAX_SCRIPT_LEN (1100)
18 //-----------------------------------------------------------------------------
22 char script[MAX_SCRIPT_LEN];
24 //-----------------------------------------------------------------------------
25 static void CatchUSR1Executer()
29 //-----------------------------------------------------------------------------
30 int ScriptExec(const char * str)
32 if (strlen(str) >= MAX_SCRIPT_LEN)
35 strncpy(sd.script, str, MAX_SCRIPT_LEN);
37 if (msgsnd(msgid, (void *)&sd, MAX_SCRIPT_LEN, 0) < 0)
42 //-----------------------------------------------------------------------------
44 void Executer(int msgID, pid_t pid, char * procName)
46 void Executer(int msgID, pid_t pid)
55 memset(procName, 0, strlen(procName));
56 strcpy(procName, "stg-exec");
58 setproctitle("stg-exec");
61 struct sigaction newsa, oldsa;
64 sigemptyset(&sigmask);
65 sigaddset(&sigmask, SIGTERM);
66 newsa.sa_handler = SIG_IGN;
67 newsa.sa_mask = sigmask;
69 sigaction(SIGTERM, &newsa, &oldsa);
71 sigemptyset(&sigmask);
72 sigaddset(&sigmask, SIGINT);
73 newsa.sa_handler = SIG_IGN;
74 newsa.sa_mask = sigmask;
76 sigaction(SIGINT, &newsa, &oldsa);
78 sigemptyset(&sigmask);
79 sigaddset(&sigmask, SIGHUP);
80 newsa.sa_handler = SIG_IGN;
81 newsa.sa_mask = sigmask;
83 sigaction(SIGHUP, &newsa, &oldsa);
85 sigemptyset(&sigmask);
86 sigaddset(&sigmask, SIGUSR1);
87 newsa.sa_handler = CatchUSR1Executer;
88 newsa.sa_mask = sigmask;
90 sigaction(SIGUSR1, &newsa, &oldsa);
94 struct SCRIPT_DATA sd;
99 ret = msgrcv(msgid, &sd, MAX_SCRIPT_LEN, 0, 0);
106 int ret = system(sd.script);
113 //-----------------------------------------------------------------------------