aboutsummaryrefslogtreecommitdiff
path: root/bin/kill/kill.c
diff options
context:
space:
mode:
authorJilles Tjoelker <jilles@FreeBSD.org>2014-03-08 19:44:34 +0000
committerJilles Tjoelker <jilles@FreeBSD.org>2014-03-08 19:44:34 +0000
commit4646e82dcddad936e873c591ce5cce0652362c0e (patch)
treedbd858bb77071b4170dbaa3bc3218ea399c009c1 /bin/kill/kill.c
parenta2be2710b4669390d74c224c40ee3bd797690c0a (diff)
downloadsrc-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/kill/kill.c')
-rw-r--r--bin/kill/kill.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/bin/kill/kill.c b/bin/kill/kill.c
index 2d41f7865e48..ab1701e03bdb 100644
--- a/bin/kill/kill.c
+++ b/bin/kill/kill.c
@@ -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);