Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/sh fix regression exit1: Don't exec the last command in ...



details:   https://anonhg.NetBSD.org/src/rev/6513717b8640
branches:  trunk
changeset: 747953:6513717b8640
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Oct 06 20:05:10 2009 +0000

description:
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.

diffstat:

 bin/sh/eval.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (35 lines):

diff -r e95457bd806e -r 6513717b8640 bin/sh/eval.c
--- a/bin/sh/eval.c     Tue Oct 06 20:03:27 2009 +0000
+++ b/bin/sh/eval.c     Tue Oct 06 20:05:10 2009 +0000
@@ -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)



Home | Main Index | Thread Index | Old Index