diff options
author | Jilles Tjoelker <jilles@FreeBSD.org> | 2014-03-08 19:44:34 +0000 |
---|---|---|
committer | Jilles Tjoelker <jilles@FreeBSD.org> | 2014-03-08 19:44:34 +0000 |
commit | 4646e82dcddad936e873c591ce5cce0652362c0e (patch) | |
tree | dbd858bb77071b4170dbaa3bc3218ea399c009c1 /bin/sh | |
parent | a2be2710b4669390d74c224c40ee3bd797690c0a (diff) | |
download | src-4646e82dcddad936e873c591ce5cce0652362c0e.tar.gz src-4646e82dcddad936e873c591ce5cce0652362c0e.zip |
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.
Notes
Notes:
svn path=/head/; revision=262931
Diffstat (limited to 'bin/sh')
-rw-r--r-- | bin/sh/jobs.c | 2 | ||||
-rw-r--r-- | bin/sh/tests/builtins/Makefile | 1 | ||||
-rw-r--r-- | bin/sh/tests/builtins/kill1.0 | 8 |
3 files changed, 11 insertions, 0 deletions
diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c index 1c0c6bd22d21..6e7791c905a4 100644 --- a/bin/sh/jobs.c +++ b/bin/sh/jobs.c @@ -645,6 +645,8 @@ getjobpgrp(char *name) struct job *jp; jp = getjob(name); + if (jp->state == JOBDONE) + return 0; return -jp->ps[0].pid; } diff --git a/bin/sh/tests/builtins/Makefile b/bin/sh/tests/builtins/Makefile index 6f60f8493c0e..b76d6312342a 100644 --- a/bin/sh/tests/builtins/Makefile +++ b/bin/sh/tests/builtins/Makefile @@ -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 diff --git a/bin/sh/tests/builtins/kill1.0 b/bin/sh/tests/builtins/kill1.0 new file mode 100644 index 000000000000..c1b85503848e --- /dev/null +++ b/bin/sh/tests/builtins/kill1.0 @@ -0,0 +1,8 @@ +# $FreeBSD$ + +: & +p1=$! +: & +p2=$! +wait $p2 +kill %1 |