From owner-svn-src-head@FreeBSD.ORG Mon Apr 25 20:54:12 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CC1F81065673; Mon, 25 Apr 2011 20:54:12 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9E91E8FC18; Mon, 25 Apr 2011 20:54:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p3PKsC6t091926; Mon, 25 Apr 2011 20:54:12 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p3PKsCaN091921; Mon, 25 Apr 2011 20:54:12 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201104252054.p3PKsCaN091921@svn.freebsd.org> From: Jilles Tjoelker Date: Mon, 25 Apr 2011 20:54:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r221027 - in head: bin/sh tools/regression/bin/sh/execution X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Apr 2011 20:54:12 -0000 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 +(:) &