aboutsummaryrefslogtreecommitdiff
path: root/bin/kill/kill.c
diff options
context:
space:
mode:
authorJilles Tjoelker <jilles@FreeBSD.org>2014-03-15 14:58:48 +0000
committerJilles Tjoelker <jilles@FreeBSD.org>2014-03-15 14:58:48 +0000
commit76961687061bd93c0158c29f839c064613aee364 (patch)
treef8932801a36ad6f4a3bffeaa6e0fb25e14c758c1 /bin/kill/kill.c
parenta5bf6b6d215821f4317ab62aa4e8add5353a3fda (diff)
downloadsrc-76961687061bd93c0158c29f839c064613aee364.tar.gz
src-76961687061bd93c0158c29f839c064613aee364.zip
sh: Allow kill %job on jobs started without job control.
When killing a %job started without job control, kill all processes in it. As with process groups and zombies, if any process in the job can be killed or has already terminated, the command is successful. This also fixes occasional failures of the builtins/kill1.0 test.
Notes
Notes: svn path=/head/; revision=263206
Diffstat (limited to 'bin/kill/kill.c')
-rw-r--r--bin/kill/kill.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/bin/kill/kill.c b/bin/kill/kill.c
index ab1701e03bdb..b23c00acf21c 100644
--- a/bin/kill/kill.c
+++ b/bin/kill/kill.c
@@ -67,7 +67,7 @@ static void usage(void);
int
main(int argc, char *argv[])
{
- int errors, numsig, pid;
+ int errors, numsig, pid, ret;
char *ep;
if (argc < 2)
@@ -133,22 +133,17 @@ main(int argc, char *argv[])
for (errors = 0; argc; argc--, argv++) {
#ifdef SHELL
- if (**argv == '%') {
- pid = getjobpgrp(*argv);
- /*
- * Silently ignore terminated jobs, like the kernel
- * silently ignores zombies.
- */
- if (pid == 0)
- continue;
- } else
+ if (**argv == '%')
+ ret = killjob(*argv, numsig);
+ else
#endif
{
pid = strtol(*argv, &ep, 10);
if (!**argv || *ep)
errx(2, "illegal process id: %s", *argv);
+ ret = kill(pid, numsig);
}
- if (kill(pid, numsig) == -1) {
+ if (ret == -1) {
warn("%s", *argv);
errors = 1;
}