]> granicus.if.org Git - procps-ng/commitdiff
kill: print usage if no pid is passed in command line
authorFilipe Brandenburger <filbranden@google.com>
Fri, 5 Jun 2015 05:27:03 +0000 (22:27 -0700)
committerFilipe Brandenburger <filbranden@google.com>
Tue, 7 Jul 2015 17:39:49 +0000 (10:39 -0700)
This makes a command such as `kill -TERM` or `kill -9` fails and prints
usage, instead of silently succeeding.

The behavior is consistent with how `kill` behaves without an explicit
signal, or with the behavior of the `kill` builtin in a shell like bash.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
skill.c

diff --git a/skill.c b/skill.c
index 9e499739fea735b99c4dca7695577f2f9d84d18c..f8f4e499d6c6b0c75ec4849b624e1784f7620285 100644 (file)
--- a/skill.c
+++ b/skill.c
@@ -493,6 +493,9 @@ static void __attribute__ ((__noreturn__))
        argc -= optind;
        argv += optind;
 
+       if (argc < 1)
+               kill_usage(stderr);
+
        for (i = 0; i < argc; i++) {
                pid = strtol_or_err(argv[i], _("failed to parse argument"));
                if (!kill((pid_t) pid, signo))