kill: print usage if no pid is passed in command line
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>
This commit is contained in:
parent
d1d2ccf732
commit
27b2937d2d
3
skill.c
3
skill.c
@ -493,6 +493,9 @@ static void __attribute__ ((__noreturn__))
|
|||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
|
if (argc < 1)
|
||||||
|
kill_usage(stderr);
|
||||||
|
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
pid = strtol_or_err(argv[i], _("failed to parse argument"));
|
pid = strtol_or_err(argv[i], _("failed to parse argument"));
|
||||||
if (!kill((pid_t) pid, signo))
|
if (!kill((pid_t) pid, signo))
|
||||||
|
Loading…
Reference in New Issue
Block a user