Module Name:    src
Committed By:   rillig
Date:           Sun Dec 27 05:16:26 UTC 2020

Modified Files:
        src/usr.bin/make: compat.c job.c main.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.216 -r1.217 src/usr.bin/make/compat.c
cvs rdiff -u -r1.389 -r1.390 src/usr.bin/make/job.c
cvs rdiff -u -r1.503 -r1.504 src/usr.bin/make/main.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/compat.c
diff -u src/usr.bin/make/compat.c:1.216 src/usr.bin/make/compat.c:1.217
--- src/usr.bin/make/compat.c:1.216	Sun Dec 20 21:07:32 2020
+++ src/usr.bin/make/compat.c	Sun Dec 27 05:16:26 2020
@@ -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, GNod
 	}
 #endif
 
+	Var_ReexportVars();
+
 	/*
 	 * Fork and execute the single command. If the fork fails, we abort.
 	 */
@@ -358,7 +360,6 @@ Compat_RunCommand(const char *cmdp, GNod
 		Fatal("Could not fork");
 	}
 	if (cpid == 0) {
-		Var_ReexportVars();
 #ifdef USE_META
 		if (useMeta) {
 			meta_compat_child();

Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.389 src/usr.bin/make/job.c:1.390
--- src/usr.bin/make/job.c:1.389	Sun Dec 20 21:07:32 2020
+++ src/usr.bin/make/job.c	Sun Dec 27 05:16:26 2020
@@ -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);
 	}

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.503 src/usr.bin/make/main.c:1.504
--- src/usr.bin/make/main.c:1.503	Sat Dec 26 03:54:48 2020
+++ src/usr.bin/make/main.c	Sun Dec 27 05:16:26 2020
@@ -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 **e
 		goto bad;
 	}
 
+	Var_ReexportVars();
+
 	/*
 	 * Fork
 	 */
@@ -1790,8 +1792,6 @@ Cmd_Exec(const char *cmd, const char **e
 		(void)dup2(pipefds[1], 1);
 		(void)close(pipefds[1]);
 
-		Var_ReexportVars();
-
 		(void)execv(shellPath, UNCONST(args));
 		_exit(1);
 		/*NOTREACHED*/

Reply via email to