Date: Sat, 8 Mar 2014 19:44:35 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> 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 Message-ID: <201403081944.s28JiZsP006138@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201403081944.s28JiZsP006138>