tech-toolchain archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
make: cannot vfork() twice - on darwin
This is "cute", only seems to impact darwin so far.
We get an error from vfork() if we've already done it
(this happens when trying to export a var that uses :sh in the child).
Index: main.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/main.c,v
retrieving revision 1.181
diff -u -p -r1.181 main.c
--- main.c 22 Apr 2010 20:25:16 -0000 1.181
+++ main.c 22 Apr 2010 22:24:34 -0000
@@ -1547,6 +1547,7 @@ Check_Cwd(const char **argv)
char *
Cmd_Exec(const char *cmd, const char **errnum)
{
+ static int mypid = 0;
const char *args[4]; /* Args for invoking the shell */
int fds[2]; /* Pipe streams */
int cpid; /* Child PID */
@@ -1560,6 +1561,10 @@ Cmd_Exec(const char *cmd, const char **e
*errnum = NULL;
+ pid = getpid();
+ if (!mypid)
+ mypid = pid;
+
if (!shellName)
Shell_Init();
/*
@@ -1581,7 +1586,17 @@ Cmd_Exec(const char *cmd, const char **e
/*
* Fork
*/
- switch (cpid = vfork()) {
+ if (pid == mypid) {
+ cpid = vfork();
+ } else {
+ /*
+ * We have already vfork'd
+ * we cannot do it again,
+ * at least on darwin.
+ */
+ cpid = fork();
+ }
+ switch (cpid) {
case 0:
/*
* Close input side of pipe
Home |
Main Index |
Thread Index |
Old Index