Some changes to launch code again
This commit is contained in:
parent
b958fdbfb3
commit
de27b8dac6
@ -10,6 +10,7 @@ v0.83.18 01-Apr-2006
|
|||||||
Removed some debug logging.
|
Removed some debug logging.
|
||||||
Fixed a small bug.
|
Fixed a small bug.
|
||||||
Code cleanup.
|
Code cleanup.
|
||||||
|
Some changes to Launch code again.
|
||||||
|
|
||||||
mbsebbs:
|
mbsebbs:
|
||||||
Fixed logging of wrong file after upload.
|
Fixed logging of wrong file after upload.
|
||||||
|
@ -465,7 +465,7 @@ int msleep(int msecs)
|
|||||||
pid_t launch(char *cmd, char *opts, char *name, int tasktype)
|
pid_t launch(char *cmd, char *opts, char *name, int tasktype)
|
||||||
{
|
{
|
||||||
static char buf[PATH_MAX];
|
static char buf[PATH_MAX];
|
||||||
char *vector[16];
|
static char *vector[16];
|
||||||
int i, rc = 0;
|
int i, rc = 0;
|
||||||
pid_t pid = 0;
|
pid_t pid = 0;
|
||||||
|
|
||||||
@ -473,7 +473,9 @@ pid_t launch(char *cmd, char *opts, char *name, int tasktype)
|
|||||||
Syslog('?', "Launch: can't execute %s, maximum tasks reached", cmd);
|
Syslog('?', "Launch: can't execute %s, maximum tasks reached", cmd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
memset(vector, 0, sizeof(vector));
|
// memset(vector, 0, sizeof(vector));
|
||||||
|
for (i = 0; i < 16; i++)
|
||||||
|
vector[i] = NULL;
|
||||||
|
|
||||||
if (opts == NULL)
|
if (opts == NULL)
|
||||||
snprintf(buf, PATH_MAX, "%s", cmd);
|
snprintf(buf, PATH_MAX, "%s", cmd);
|
||||||
@ -485,11 +487,16 @@ pid_t launch(char *cmd, char *opts, char *name, int tasktype)
|
|||||||
while ((vector[i++] = strtok(NULL," \t\n")) && (i<16));
|
while ((vector[i++] = strtok(NULL," \t\n")) && (i<16));
|
||||||
vector[15] = NULL;
|
vector[15] = NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < 16; i++)
|
||||||
|
if (vector[i])
|
||||||
|
Syslog('l', "Launch: i=%d vector=\"%s\"", i, vector[i]);
|
||||||
|
|
||||||
if (file_exist(vector[0], X_OK)) {
|
if (file_exist(vector[0], X_OK)) {
|
||||||
Syslog('?', "Launch: can't execute %s, command not found", vector[0]);
|
Syslog('?', "Launch: can't execute %s, command not found", vector[0]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Syslog('l', "Launch: b4 fork()");
|
||||||
switch (pid = fork()) {
|
switch (pid = fork()) {
|
||||||
case -1:
|
case -1:
|
||||||
WriteError("$Launch: error, can't fork grandchild");
|
WriteError("$Launch: error, can't fork grandchild");
|
||||||
@ -500,6 +507,7 @@ pid_t launch(char *cmd, char *opts, char *name, int tasktype)
|
|||||||
* before the main process sees it ever started.
|
* before the main process sees it ever started.
|
||||||
*/
|
*/
|
||||||
msleep(150);
|
msleep(150);
|
||||||
|
Syslog('l', "Launch: child process");
|
||||||
|
|
||||||
/* From Paul Vixies cron: */
|
/* From Paul Vixies cron: */
|
||||||
rc = setsid(); /* It doesn't seem to help */
|
rc = setsid(); /* It doesn't seem to help */
|
||||||
@ -530,6 +538,8 @@ pid_t launch(char *cmd, char *opts, char *name, int tasktype)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Syslog('l', "Launch: parent process");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add it to the tasklist.
|
* Add it to the tasklist.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user