On darwin at least, vfork() fails in child of vfork().
It probably shouldn't work anyway, so avoid this. We use the macro vFork() - a function seems to cause problems and is unnecessary overhead.
This commit is contained in:
parent
d1466497fc
commit
24157036cd
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: compat.c,v 1.77 2010/04/07 00:11:27 sjg Exp $ */
|
||||
/* $NetBSD: compat.c,v 1.78 2010/04/23 00:18:50 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
|
@ -70,14 +70,14 @@
|
|||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: compat.c,v 1.77 2010/04/07 00:11:27 sjg Exp $";
|
||||
static char rcsid[] = "$NetBSD: compat.c,v 1.78 2010/04/23 00:18:50 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: compat.c,v 1.77 2010/04/07 00:11:27 sjg Exp $");
|
||||
__RCSID("$NetBSD: compat.c,v 1.78 2010/04/23 00:18:50 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
@ -355,7 +355,7 @@ again:
|
|||
/*
|
||||
* Fork and execute the single command. If the fork fails, we abort.
|
||||
*/
|
||||
cpid = vfork();
|
||||
cpid = vFork();
|
||||
if (cpid < 0) {
|
||||
Fatal("Could not fork");
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: job.c,v 1.148 2010/04/22 19:11:17 sjg Exp $ */
|
||||
/* $NetBSD: job.c,v 1.149 2010/04/23 00:18:50 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
|
@ -70,14 +70,14 @@
|
|||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: job.c,v 1.148 2010/04/22 19:11:17 sjg Exp $";
|
||||
static char rcsid[] = "$NetBSD: job.c,v 1.149 2010/04/23 00:18:50 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: job.c,v 1.148 2010/04/22 19:11:17 sjg Exp $");
|
||||
__RCSID("$NetBSD: job.c,v 1.149 2010/04/23 00:18:50 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
@ -1299,7 +1299,7 @@ JobExec(Job *job, char **argv)
|
|||
/* Pre-emptively mark job running, pid still zero though */
|
||||
job->job_state = JOB_ST_RUNNING;
|
||||
|
||||
cpid = vfork();
|
||||
cpid = vFork();
|
||||
if (cpid == -1)
|
||||
Punt("Cannot vfork: %s", strerror(errno));
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: main.c,v 1.182 2010/04/22 22:39:13 dholland Exp $ */
|
||||
/* $NetBSD: main.c,v 1.183 2010/04/23 00:18:50 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
|
@ -69,7 +69,7 @@
|
|||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: main.c,v 1.182 2010/04/22 22:39:13 dholland Exp $";
|
||||
static char rcsid[] = "$NetBSD: main.c,v 1.183 2010/04/23 00:18:50 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
|
@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: main.c,v 1.182 2010/04/22 22:39:13 dholland Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.183 2010/04/23 00:18:50 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
@ -185,6 +185,7 @@ static char curdir[MAXPATHLEN + 1]; /* startup directory */
|
|||
static char objdir[MAXPATHLEN + 1]; /* where we chdir'ed to */
|
||||
char *progname; /* the program name */
|
||||
char *makeDependfile;
|
||||
pid_t myPid;
|
||||
|
||||
Boolean forceJobs = FALSE;
|
||||
|
||||
|
@ -842,6 +843,8 @@ main(int argc, char **argv)
|
|||
#endif
|
||||
}
|
||||
|
||||
myPid = getpid(); /* remember this for vFork() */
|
||||
|
||||
/*
|
||||
* Just in case MAKEOBJDIR wants us to do something tricky.
|
||||
*/
|
||||
|
@ -923,7 +926,7 @@ main(int argc, char **argv)
|
|||
ep = "0";
|
||||
}
|
||||
Var_Set(MAKE_LEVEL, ep, VAR_GLOBAL, 0);
|
||||
snprintf(tmp, sizeof(tmp), "%u", getpid());
|
||||
snprintf(tmp, sizeof(tmp), "%u", myPid);
|
||||
Var_Set(".MAKE.PID", tmp, VAR_GLOBAL, 0);
|
||||
snprintf(tmp, sizeof(tmp), "%u", getppid());
|
||||
Var_Set(".MAKE.PPID", tmp, VAR_GLOBAL, 0);
|
||||
|
@ -1581,7 +1584,7 @@ Cmd_Exec(const char *cmd, const char **errnum)
|
|||
/*
|
||||
* Fork
|
||||
*/
|
||||
switch (cpid = vfork()) {
|
||||
switch (cpid = vFork()) {
|
||||
case 0:
|
||||
/*
|
||||
* Close input side of pipe
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: make.h,v 1.81 2010/04/22 19:11:17 sjg Exp $ */
|
||||
/* $NetBSD: make.h,v 1.82 2010/04/23 00:18:50 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
|
@ -395,6 +395,13 @@ extern Lst defIncPath; /* The default include path. */
|
|||
extern char *progname; /* The program name */
|
||||
extern char *makeDependfile; /* .depend */
|
||||
|
||||
/*
|
||||
* We cannot vfork() in a child of vfork().
|
||||
* Most systems do not enforce this but some do.
|
||||
*/
|
||||
#define vFork() ((getpid() == myPid) ? vfork() : fork())
|
||||
extern pid_t myPid;
|
||||
|
||||
#define MAKEFLAGS ".MAKEFLAGS"
|
||||
#define MAKEOVERRIDES ".MAKEOVERRIDES"
|
||||
#define MAKE_JOB_PREFIX ".MAKE.JOB.PREFIX" /* prefix for job target output */
|
||||
|
|
Loading…
Reference in New Issue