Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/sh explain why forks fail
details: https://anonhg.NetBSD.org/src/rev/a92531960978
branches: trunk
changeset: 326362:a92531960978
user: christos <christos%NetBSD.org@localhost>
date: Sun Jan 26 22:38:20 2014 +0000
description:
explain why forks fail
diffstat:
bin/sh/eval.c | 10 ++++++----
bin/sh/jobs.c | 12 +++++++-----
2 files changed, 13 insertions(+), 9 deletions(-)
diffs (76 lines):
diff -r 277cf83eaba1 -r a92531960978 bin/sh/eval.c
--- a/bin/sh/eval.c Sun Jan 26 21:47:00 2014 +0000
+++ b/bin/sh/eval.c Sun Jan 26 22:38:20 2014 +0000
@@ -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 @@
*/
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
diff -r 277cf83eaba1 -r a92531960978 bin/sh/jobs.c
--- a/bin/sh/jobs.c Sun Jan 26 21:47:00 2014 +0000
+++ b/bin/sh/jobs.c Sun Jan 26 22:38:20 2014 +0000
@@ -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 @@
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);
Home |
Main Index |
Thread Index |
Old Index