summaryrefslogtreecommitdiff
path: root/usr.bin/make
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2020-12-27 05:16:26 +0000
committerrillig <rillig@NetBSD.org>2020-12-27 05:16:26 +0000
commit9940dd6fa1142e51f04df7b4cd6b2aa467e31600 (patch)
tree424170476fc94b729d217f6fcc5ffe4fb188daa2 /usr.bin/make
parent57b23abc0f734d85857dd3435b0ecadb47f04bf6 (diff)
make(1): re-export variables from the actual make process
Since make uses vfork if available, re-exporting the variables happens in the address space of the main process anyway, so there is no point in mentioning anything about "our client process" anywhere.
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/compat.c7
-rw-r--r--usr.bin/make/job.c8
-rw-r--r--usr.bin/make/main.c8
3 files changed, 12 insertions, 11 deletions
diff --git a/usr.bin/make/compat.c b/usr.bin/make/compat.c
index 161f31220ba..6a3d21cf52a 100644
--- a/usr.bin/make/compat.c
+++ b/usr.bin/make/compat.c
@@ -1,4 +1,4 @@
-/* $NetBSD: compat.c,v 1.216 2020/12/20 21:07:32 rillig Exp $ */
+/* $NetBSD: compat.c,v 1.217 2020/12/27 05:16:26 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
#include "pathnames.h"
/* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: compat.c,v 1.216 2020/12/20 21:07:32 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.217 2020/12/27 05:16:26 rillig Exp $");
static GNode *curTarg = NULL;
static pid_t compatChild;
@@ -350,6 +350,8 @@ Compat_RunCommand(const char *cmdp, GNode *gn, StringListNode *ln)
}
#endif
+ Var_ReexportVars();
+
/*
* Fork and execute the single command. If the fork fails, we abort.
*/
@@ -358,7 +360,6 @@ Compat_RunCommand(const char *cmdp, GNode *gn, StringListNode *ln)
Fatal("Could not fork");
}
if (cpid == 0) {
- Var_ReexportVars();
#ifdef USE_META
if (useMeta) {
meta_compat_child();
diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c
index 46f6fcc8877..dcc08875029 100644
--- a/usr.bin/make/job.c
+++ b/usr.bin/make/job.c
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.389 2020/12/20 21:07:32 rillig Exp $ */
+/* $NetBSD: job.c,v 1.390 2020/12/27 05:16:26 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -143,7 +143,7 @@
#include "trace.h"
/* "@(#)job.c 8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: job.c,v 1.389 2020/12/20 21:07:32 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.390 2020/12/27 05:16:26 rillig Exp $");
/*
* A shell defines how the commands are run. All commands for a target are
@@ -1380,6 +1380,8 @@ JobExec(Job *job, char **argv)
/* Pre-emptively mark job running, pid still zero though */
job->status = JOB_ST_RUNNING;
+ Var_ReexportVars();
+
cpid = vFork();
if (cpid == -1)
Punt("Cannot vfork: %s", strerror(errno));
@@ -1461,8 +1463,6 @@ JobExec(Job *job, char **argv)
# endif
#endif
- Var_ReexportVars();
-
(void)execv(shellPath, argv);
execDie("exec", shellPath);
}
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c
index 36779086a26..10b357e35ab 100644
--- a/usr.bin/make/main.c
+++ b/usr.bin/make/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.503 2020/12/26 03:54:48 sjg Exp $ */
+/* $NetBSD: main.c,v 1.504 2020/12/27 05:16:26 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
#include "trace.h"
/* "@(#)main.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.503 2020/12/26 03:54:48 sjg Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.504 2020/12/27 05:16:26 rillig Exp $");
#if defined(MAKE_NATIVE) && !defined(lint)
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
"The Regents of the University of California. "
@@ -1775,6 +1775,8 @@ Cmd_Exec(const char *cmd, const char **errfmt)
goto bad;
}
+ Var_ReexportVars();
+
/*
* Fork
*/
@@ -1790,8 +1792,6 @@ Cmd_Exec(const char *cmd, const char **errfmt)
(void)dup2(pipefds[1], 1);
(void)close(pipefds[1]);
- Var_ReexportVars();
-
(void)execv(shellPath, UNCONST(args));
_exit(1);
/*NOTREACHED*/