From owner-svn-src-head@FreeBSD.ORG Sat Mar 8 19:44:36 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 399F5240; Sat, 8 Mar 2014 19:44:36 +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 0C5C825B; Sat, 8 Mar 2014 19:44:36 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s28JiZDN006142; Sat, 8 Mar 2014 19:44:35 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s28JiZsP006138; Sat, 8 Mar 2014 19:44:35 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201403081944.s28JiZsP006138@svn.freebsd.org> From: Jilles Tjoelker Date: Sat, 8 Mar 2014 19:44:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r262931 - in head/bin: kill sh sh/tests/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.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: Sat, 08 Mar 2014 19:44:36 -0000 Author: jilles Date: Sat Mar 8 19:44:34 2014 New Revision: 262931 URL: http://svnweb.freebsd.org/changeset/base/262931 Log: sh: Successfully do nothing when killing a terminated job. If a job has terminated but is still known, silently do nothing when using the kill builtin with the job specifier. Formerly, the shell called kill() with the process group ID that might have been reused. Added: head/bin/sh/tests/builtins/kill1.0 (contents, props changed) Modified: head/bin/kill/kill.c head/bin/sh/jobs.c head/bin/sh/tests/builtins/Makefile Modified: head/bin/kill/kill.c ============================================================================== --- head/bin/kill/kill.c Sat Mar 8 19:35:31 2014 (r262930) +++ head/bin/kill/kill.c Sat Mar 8 19:44:34 2014 (r262931) @@ -133,9 +133,15 @@ main(int argc, char *argv[]) for (errors = 0; argc; argc--, argv++) { #ifdef SHELL - if (**argv == '%') + if (**argv == '%') { pid = getjobpgrp(*argv); - else + /* + * Silently ignore terminated jobs, like the kernel + * silently ignores zombies. + */ + if (pid == 0) + continue; + } else #endif { pid = strtol(*argv, &ep, 10); Modified: head/bin/sh/jobs.c ============================================================================== --- head/bin/sh/jobs.c Sat Mar 8 19:35:31 2014 (r262930) +++ head/bin/sh/jobs.c Sat Mar 8 19:44:34 2014 (r262931) @@ -645,6 +645,8 @@ getjobpgrp(char *name) struct job *jp; jp = getjob(name); + if (jp->state == JOBDONE) + return 0; return -jp->ps[0].pid; } Modified: head/bin/sh/tests/builtins/Makefile ============================================================================== --- head/bin/sh/tests/builtins/Makefile Sat Mar 8 19:35:31 2014 (r262930) +++ head/bin/sh/tests/builtins/Makefile Sat Mar 8 19:44:34 2014 (r262931) @@ -86,6 +86,7 @@ FILES+= hash3.0 hash3.0.stdout FILES+= hash4.0 FILES+= jobid1.0 FILES+= jobid2.0 +FILES+= kill1.0 FILES+= lineno.0 lineno.0.stdout FILES+= lineno2.0 FILES+= local1.0 Added: head/bin/sh/tests/builtins/kill1.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/builtins/kill1.0 Sat Mar 8 19:44:34 2014 (r262931) @@ -0,0 +1,8 @@ +# $FreeBSD$ + +: & +p1=$! +: & +p2=$! +wait $p2 +kill %1