Module Name: src
Committed By: christos
Date: Tue Oct 6 20:05:10 UTC 2009
Modified Files:
src/bin/sh: eval.c
Log Message:
fix regression exit1: Don't exec the last command in a subshell if it has
trap[0] (trap EXIT) set. Fork instead to give the shell a chance to execute
the trap when it is done.
To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/bin/sh/eval.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/bin/sh/eval.c
diff -u src/bin/sh/eval.c:1.96 src/bin/sh/eval.c:1.97
--- src/bin/sh/eval.c:1.96 Mon Jan 19 14:47:11 2009
+++ src/bin/sh/eval.c Tue Oct 6 16:05:10 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: eval.c,v 1.96 2009/01/19 19:47:11 christos Exp $ */
+/* $NetBSD: eval.c,v 1.97 2009/10/06 20:05:10 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.96 2009/01/19 19:47:11 christos Exp $");
+__RCSID("$NetBSD: eval.c,v 1.97 2009/10/06 20:05:10 christos Exp $");
#endif
#endif /* not lint */
@@ -665,6 +665,7 @@
}
int vforked = 0;
+extern char *trap[];
/*
* Execute a simple command.
@@ -820,7 +821,7 @@
}
/* Fork off a child process if necessary. */
- if (cmd->ncmd.backgnd
+ if (cmd->ncmd.backgnd || trap[0]
|| (cmdentry.cmdtype == CMDNORMAL && (flags & EV_EXIT) == 0)
|| ((flags & EV_BACKCMD) != 0
&& ((cmdentry.cmdtype != CMDBUILTIN && cmdentry.cmdtype != CMDSPLBLTIN)