From owner-svn-src-head@FreeBSD.ORG Thu Mar 20 22:38:13 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D5B56387; Thu, 20 Mar 2014 22:38:13 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C22A8E63; Thu, 20 Mar 2014 22:38:13 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s2KMcDTh061377; Thu, 20 Mar 2014 22:38:13 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s2KMcDBJ061376; Thu, 20 Mar 2014 22:38:13 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201403202238.s2KMcDBJ061376@svn.freebsd.org> From: Jilles Tjoelker Date: Thu, 20 Mar 2014 22:38:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r263453 - head/bin/sh X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 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: Thu, 20 Mar 2014 22:38:13 -0000 Author: jilles Date: Thu Mar 20 22:38:13 2014 New Revision: 263453 URL: http://svnweb.freebsd.org/changeset/base/263453 Log: sh: Don't overwrite old exit status if a PID is reused. Only store exit status for a process if that process has not terminated yet. Test (slow): exit 7 & p1=$!; until exit 8 & p2=$!; [ "$p1" = "$p2" ]; do wait "$p2"; done; sleep 0.1; wait %1; echo $? should write "7". Modified: head/bin/sh/jobs.c Modified: head/bin/sh/jobs.c ============================================================================== --- head/bin/sh/jobs.c Thu Mar 20 22:03:37 2014 (r263452) +++ head/bin/sh/jobs.c Thu Mar 20 22:38:13 2014 (r263453) @@ -1121,7 +1121,8 @@ dowait(int mode, struct job *job) for (sp = jp->ps ; sp < jp->ps + jp->nprocs ; sp++) { if (sp->pid == -1) continue; - if (sp->pid == pid) { + if (sp->pid == pid && (sp->status == -1 || + WIFSTOPPED(sp->status))) { TRACE(("Changing status of proc %d from 0x%x to 0x%x\n", (int)pid, sp->status, status));