summaryrefslogtreecommitdiffstats
path: root/usr.bin/make
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2005-05-12 15:54:17 +0000
committerharti <harti@FreeBSD.org>2005-05-12 15:54:17 +0000
commit8a553d2355a2ebf98fd5facbdb26efae0acafe18 (patch)
tree7d044f0e0017f76e3bf7509873204fddf9a800e1 /usr.bin/make
parent585f572c6c442d71cb51648c67b6228bcca58c99 (diff)
downloadFreeBSD-src-8a553d2355a2ebf98fd5facbdb26efae0acafe18.zip
FreeBSD-src-8a553d2355a2ebf98fd5facbdb26efae0acafe18.tar.gz
Get rid of the warning about vfork() clobbering variables.
Submitted by: Max Okumoto <okumoto@ucsd.edu> (7.246)
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/job.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c
index 502d387..b9be4db 100644
--- a/usr.bin/make/job.c
+++ b/usr.bin/make/job.c
@@ -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) {
/*
OpenPOWER on IntegriCloud