explain why forks fail

This commit is contained in:
christos 2014-01-26 22:38:20 +00:00
parent 638199ebfd
commit 1468e9a310
2 changed files with 13 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: eval.c,v 1.107 2013/06/27 23:22:04 yamt Exp $ */
/* $NetBSD: eval.c,v 1.108 2014/01/26 22:38:20 christos Exp $ */
/*-
* Copyright (c) 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95";
#else
__RCSID("$NetBSD: eval.c,v 1.107 2013/06/27 23:22:04 yamt Exp $");
__RCSID("$NetBSD: eval.c,v 1.108 2014/01/26 22:38:20 christos Exp $");
#endif
#endif /* not lint */
@ -845,15 +845,17 @@ evalcommand(union node *cmd, int flgs, struct backcmd *backcmd)
*/
if (cmdentry.cmdtype == CMDNORMAL) {
pid_t pid;
int serrno;
savelocalvars = localvars;
localvars = NULL;
vforked = 1;
switch (pid = vfork()) {
case -1:
TRACE(("Vfork failed, errno=%d\n", errno));
serrno = errno;
TRACE(("Vfork failed, errno=%d\n", serrno));
INTON;
error("Cannot vfork");
error("Cannot vfork (%s)", strerror(serrno));
break;
case 0:
/* Make sure that exceptions only unwind to

View File

@ -1,4 +1,4 @@
/* $NetBSD: jobs.c,v 1.71 2012/12/31 14:10:15 dsl Exp $ */
/* $NetBSD: jobs.c,v 1.72 2014/01/26 22:38:20 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95";
#else
__RCSID("$NetBSD: jobs.c,v 1.71 2012/12/31 14:10:15 dsl Exp $");
__RCSID("$NetBSD: jobs.c,v 1.72 2014/01/26 22:38:20 christos Exp $");
#endif
#endif /* not lint */
@ -858,14 +858,16 @@ makejob(union node *node, int nprocs)
int
forkshell(struct job *jp, union node *n, int mode)
{
int pid;
pid_t pid;
int serrno;
TRACE(("forkshell(%%%d, %p, %d) called\n", jp - jobtab, n, mode));
switch ((pid = fork())) {
case -1:
TRACE(("Fork failed, errno=%d\n", errno));
serrno = errno;
TRACE(("Fork failed, errno=%d\n", serrno));
INTON;
error("Cannot fork");
error("Cannot fork (%s)", strerror(serrno));
break;
case 0:
forkchild(jp, n, mode, 0);