From owner-svn-src-head@FreeBSD.ORG Wed Jun 5 19:40:53 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id D0523812; Wed, 5 Jun 2013 19:40:53 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id A5B991D35; Wed, 5 Jun 2013 19:40:53 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r55JeruX015443; Wed, 5 Jun 2013 19:40:53 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r55Jeqah015440; Wed, 5 Jun 2013 19:40:52 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201306051940.r55Jeqah015440@svn.freebsd.org> From: Jilles Tjoelker Date: Wed, 5 Jun 2013 19:40:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r251430 - in head: bin/sh tools/regression/bin/sh/builtins 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.14 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: Wed, 05 Jun 2013 19:40:53 -0000 Author: jilles Date: Wed Jun 5 19:40:52 2013 New Revision: 251430 URL: http://svnweb.freebsd.org/changeset/base/251430 Log: sh: Return status 127 for unknown jobs in wait builtin. This is required by POSIX, at least for pids that are not known child processes. Other problems with job specifications still cause wait to abort with exit status 2. PR: 176916 Added: head/tools/regression/bin/sh/builtins/wait10.0 (contents, props changed) head/tools/regression/bin/sh/builtins/wait9.127 (contents, props changed) Modified: head/bin/sh/jobs.c Modified: head/bin/sh/jobs.c ============================================================================== --- head/bin/sh/jobs.c Wed Jun 5 19:08:22 2013 (r251429) +++ head/bin/sh/jobs.c Wed Jun 5 19:40:52 2013 (r251430) @@ -96,6 +96,7 @@ static void restartjob(struct job *); #endif static void freejob(struct job *); static int waitcmdloop(struct job *); +static struct job *getjob_nonotfound(char *); static struct job *getjob(char *); pid_t getjobpgrp(char *); static pid_t dowait(int, struct job *); @@ -467,8 +468,11 @@ waitcmd(int argc __unused, char **argv _ return (waitcmdloop(NULL)); do { - job = getjob(*argptr); - retval = waitcmdloop(job); + job = getjob_nonotfound(*argptr); + if (job == NULL) + retval = 127; + else + retval = waitcmdloop(job); argptr++; } while (*argptr != NULL); @@ -558,7 +562,7 @@ jobidcmd(int argc __unused, char **argv) */ static struct job * -getjob(char *name) +getjob_nonotfound(char *name) { int jobno; struct job *found, *jp; @@ -623,12 +627,22 @@ currentjob: if ((jp = getcurjob(NULL)) = return jp; } } - error("No such job: %s", name); - /*NOTREACHED*/ return NULL; } +static struct job * +getjob(char *name) +{ + struct job *jp; + + jp = getjob_nonotfound(name); + if (jp == NULL) + error("No such job: %s", name); + return (jp); +} + + pid_t getjobpgrp(char *name) { Added: head/tools/regression/bin/sh/builtins/wait10.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/builtins/wait10.0 Wed Jun 5 19:40:52 2013 (r251430) @@ -0,0 +1,5 @@ +# $FreeBSD$ +# Init cannot be a child of the shell. +exit 49 & p49=$! +wait 1 "$p49" +[ "$?" = 49 ] Added: head/tools/regression/bin/sh/builtins/wait9.127 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/builtins/wait9.127 Wed Jun 5 19:40:52 2013 (r251430) @@ -0,0 +1,3 @@ +# $FreeBSD$ +# Init cannot be a child of the shell. +wait 1