Get rid of the warning about vfork() clobbering variables.

Submitted by:	Max Okumoto <okumoto@ucsd.edu> (7.246)
This commit is contained in:
harti 2005-05-12 15:54:17 +00:00
parent 585f572c6c
commit 8a553d2355

View File

@ -491,6 +491,8 @@ typedef struct ProcStuff {
int searchpath; /* true if binary should be found via $PATH */
char **argv;
int argv_free; /* release argv after use */
int errCheck;
pid_t child_pid;
} ProcStuff;
@ -1579,6 +1581,7 @@ JobExec(Job *job, char **argv)
ps.searchpath = 0;
ps.argv = argv;
ps.argv_free = 0;
/*
* Fork. Warning since we are doing vfork() instead of fork(),
@ -3251,6 +3254,7 @@ Cmd_Exec(const char *cmd, const char **error)
ps.argv[1] = strdup("-c");
ps.argv[2] = strdup(cmd);
ps.argv[3] = NULL;
ps.argv_free = 1;
/*
* Fork. Warning since we are doing vfork() instead of fork(),
@ -3432,7 +3436,6 @@ Compat_RunCommand(char *cmd, GNode *gn)
int status; /* Description of child's death */
LstNode *cmdNode; /* Node where current command is located */
char **av; /* Argument vector for thing to exec */
char *cmd_save; /* saved cmd */
ProcStuff ps;
silent = gn->type & OP_SILENT;
@ -3522,9 +3525,12 @@ Compat_RunCommand(char *cmd, GNode *gn)
ps.argv[1] = strdup(errCheck ? "-ec" : "-c");
ps.argv[2] = strdup(cmd);
ps.argv[3] = NULL;
ps.argv_free = 1;
} else {
ps.argv = av;
ps.argv_free = 0;
}
ps.errCheck = errCheck;
/*
* Warning since we are doing vfork() instead of fork(),
@ -3541,7 +3547,7 @@ Compat_RunCommand(char *cmd, GNode *gn)
/* NOTREACHED */
} else {
if (av == NULL) {
if (ps.argv_free) {
free(ps.argv[2]);
free(ps.argv[1]);
free(ps.argv[0]);
@ -3556,7 +3562,6 @@ Compat_RunCommand(char *cmd, GNode *gn)
*/
if (!DEBUG(GRAPH2)) {
free(cmdStart);
Lst_Replace(cmdNode, cmd_save);
}
/*
@ -3585,7 +3590,7 @@ Compat_RunCommand(char *cmd, GNode *gn)
printf("*** Signal %d", status);
}
if (errCheck) {
if (ps.errCheck) {
gn->made = ERROR;
if (keepgoing) {
/*