Some changes to launch code again

This commit is contained in:
Michiel Broek 2006-05-23 19:18:52 +00:00
parent b958fdbfb3
commit de27b8dac6
2 changed files with 13 additions and 2 deletions

View File

@ -10,6 +10,7 @@ v0.83.18 01-Apr-2006
Removed some debug logging.
Fixed a small bug.
Code cleanup.
Some changes to Launch code again.
mbsebbs:
Fixed logging of wrong file after upload.

View File

@ -465,7 +465,7 @@ int msleep(int msecs)
pid_t launch(char *cmd, char *opts, char *name, int tasktype)
{
static char buf[PATH_MAX];
char *vector[16];
static char *vector[16];
int i, rc = 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);
return 0;
}
memset(vector, 0, sizeof(vector));
// memset(vector, 0, sizeof(vector));
for (i = 0; i < 16; i++)
vector[i] = NULL;
if (opts == NULL)
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));
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)) {
Syslog('?', "Launch: can't execute %s, command not found", vector[0]);
return 0;
}
Syslog('l', "Launch: b4 fork()");
switch (pid = fork()) {
case -1:
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.
*/
msleep(150);
Syslog('l', "Launch: child process");
/* From Paul Vixies cron: */
rc = setsid(); /* It doesn't seem to help */
@ -530,6 +538,8 @@ pid_t launch(char *cmd, char *opts, char *name, int tasktype)
break;
}
Syslog('l', "Launch: parent process");
/*
* Add it to the tasklist.
*/