16 #define MAX_SCRIPT_LEN (256)
21 //-----------------------------------------------------------------------------
25 char script[MAX_SCRIPT_LEN];
27 //-----------------------------------------------------------------------------
28 static void CatchUSR1Executer(int)
30 //printfd(__FILE__, "CatchUSR1Executer\n");
34 //-----------------------------------------------------------------------------
35 int ScriptExec(const string & str)
37 if (str.length() >= MAX_SCRIPT_LEN)
40 /*printfd(__FILE__, "2 Script schedule: %s\n", str.c_str());
42 if (access(str.c_str(), X_OK))
47 strncpy(sd.script, str.c_str(), MAX_SCRIPT_LEN);
49 mbuf = (struct msgbuf * )&sd;
50 ret = msgsnd(msgid, mbuf, MAX_SCRIPT_LEN, 0);
53 printfd(__FILE__, "snd ERROR!\n");
58 //-----------------------------------------------------------------------------
59 void Executer(int msgKey, int msgID, pid_t pid, char * procName)
65 //printfd(__FILE__, "close(pipeOut) %d pid=%d\n", pipeOut, getpid());
67 //printfd(__FILE__, "Executer started %d\n", getpid());
69 memset(procName, 0, strlen(procName));
70 strcpy(procName, "stg-exec");
72 setproctitle("stg-exec");
75 struct sigaction newsa, oldsa;
78 sigemptyset(&sigmask);
79 sigaddset(&sigmask, SIGTERM);
80 newsa.sa_handler = SIG_IGN;
81 newsa.sa_mask = sigmask;
83 sigaction(SIGTERM, &newsa, &oldsa);
85 sigemptyset(&sigmask);
86 sigaddset(&sigmask, SIGINT);
87 newsa.sa_handler = SIG_IGN;
88 newsa.sa_mask = sigmask;
90 sigaction(SIGINT, &newsa, &oldsa);
92 sigemptyset(&sigmask);
93 sigaddset(&sigmask, SIGUSR1);
94 newsa.sa_handler = CatchUSR1Executer;
95 newsa.sa_mask = sigmask;
97 sigaction(SIGUSR1, &newsa, &oldsa);
106 //printfd(__FILE__, "Waiting for msgrcv... msgid=%d pid=%d\n", msgid, getpid());
107 ret = msgrcv(msgid, &sd, MAX_SCRIPT_LEN, 0, 0);
114 //printfd(__FILE__, "Script execute: %s\n", sd.script);
119 //-----------------------------------------------------------------------------