svn commit: r221027 - in head: bin/sh tools/regression/bin/sh/execution

Jilles Tjoelker jilles at FreeBSD.org
Mon Apr 25 20:54:12 UTC 2011


Author: jilles
Date: Mon Apr 25 20:54:12 2011
New Revision: 221027
URL: http://svn.freebsd.org/changeset/base/221027

Log:
  sh: Set $? to 0 for background commands.
  
  For backgrounded pipelines and subshells, the previous value of $? was being
  preserved, which is incorrect.
  
  For backgrounded simple commands containing a command substitution, the
  status of the last command substitution was returned instead of 0.
  
  If fork() fails, this is an error.

Added:
  head/tools/regression/bin/sh/execution/bg1.0   (contents, props changed)
  head/tools/regression/bin/sh/execution/bg2.0   (contents, props changed)
  head/tools/regression/bin/sh/execution/bg3.0   (contents, props changed)
Modified:
  head/bin/sh/eval.c

Modified: head/bin/sh/eval.c
==============================================================================
--- head/bin/sh/eval.c	Mon Apr 25 19:15:58 2011	(r221026)
+++ head/bin/sh/eval.c	Mon Apr 25 20:54:12 2011	(r221027)
@@ -420,7 +420,8 @@ evalsubshell(union node *n, int flags)
 		INTOFF;
 		exitstatus = waitforjob(jp, (int *)NULL);
 		INTON;
-	}
+	} else
+		exitstatus = 0;
 }
 
 
@@ -559,7 +560,8 @@ evalpipe(union node *n)
 		exitstatus = waitforjob(jp, (int *)NULL);
 		TRACE(("evalpipe:  job done exit status %d\n", exitstatus));
 		INTON;
-	}
+	} else
+		exitstatus = 0;
 }
 
 
@@ -1056,7 +1058,8 @@ parent:	/* parent process gets here (if 
 		backcmd->fd = pip[0];
 		close(pip[1]);
 		backcmd->jp = jp;
-	}
+	} else
+		exitstatus = 0;
 
 out:
 	if (lastarg)

Added: head/tools/regression/bin/sh/execution/bg1.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/regression/bin/sh/execution/bg1.0	Mon Apr 25 20:54:12 2011	(r221027)
@@ -0,0 +1,3 @@
+# $FreeBSD$
+
+: `false` &

Added: head/tools/regression/bin/sh/execution/bg2.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/regression/bin/sh/execution/bg2.0	Mon Apr 25 20:54:12 2011	(r221027)
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+f() { return 42; }
+f
+: | : &

Added: head/tools/regression/bin/sh/execution/bg3.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/regression/bin/sh/execution/bg3.0	Mon Apr 25 20:54:12 2011	(r221027)
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+f() { return 42; }
+f
+(:) &


More information about the svn-src-all mailing list