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.
This commit is contained in:
rillig 2020-12-27 05:16:26 +00:00
parent 0134a24c0d
commit eb9a329939
3 changed files with 12 additions and 11 deletions

View File

@ -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();

View File

@ -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);
}

View File

@ -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*/