diff options
author | Ron Yorston <rmy@pobox.com> | 2017-08-27 08:25:18 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-08-28 14:03:13 +0200 |
commit | 0b6ec06bebc8774ed3b70857ff81901aca4804f4 (patch) | |
tree | d00839e93316f42cf8fd450015ff4cadd4c31e37 /procps | |
parent | 14551b7036acf98f81d76674f351ce99148762c8 (diff) | |
download | busybox-w32-0b6ec06bebc8774ed3b70857ff81901aca4804f4.tar.gz busybox-w32-0b6ec06bebc8774ed3b70857ff81901aca4804f4.tar.bz2 busybox-w32-0b6ec06bebc8774ed3b70857ff81901aca4804f4.zip |
kill: add '--' option to separate options from arguments
Using a negative pid to send TERM to a process group results in an
obscure error:
$ ./busybox kill -12345
kill: bad signal name '12345'
This is intended. Manpage says:
ARGUMENTS
pid Each pid can be one of four things:
...
-n where n is larger than 1. All processes in process group
n are signaled. When an argument of the form '-n' is
given, and it is meant to denote a process group, either
a signal must be specified first, or the argument must be
preceded by a '--' option, otherwise it will be taken as
the signal to send.
However, we did not support "--". Add this capability to BusyBox.
function old new delta
kill_main 993 999 +6
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'procps')
-rw-r--r-- | procps/kill.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/procps/kill.c b/procps/kill.c index 0ddae2f70..24cc903fc 100644 --- a/procps/kill.c +++ b/procps/kill.c | |||
@@ -184,6 +184,10 @@ int kill_main(int argc UNUSED_PARAM, char **argv) | |||
184 | if (is_killall5 && arg[0] == 'o') | 184 | if (is_killall5 && arg[0] == 'o') |
185 | goto do_it_now; | 185 | goto do_it_now; |
186 | 186 | ||
187 | /* "--" separates options from args. Testcase: "kill -- -123" */ | ||
188 | if (!is_killall5 && arg[0] == '-' && arg[1] == '\0') | ||
189 | goto do_it_sooner; | ||
190 | |||
187 | if (argv[1] && arg[0] == 's' && arg[1] == '\0') { /* -s SIG? */ | 191 | if (argv[1] && arg[0] == 's' && arg[1] == '\0') { /* -s SIG? */ |
188 | arg = *++argv; | 192 | arg = *++argv; |
189 | } /* else it must be -SIG */ | 193 | } /* else it must be -SIG */ |
@@ -192,6 +196,7 @@ int kill_main(int argc UNUSED_PARAM, char **argv) | |||
192 | bb_error_msg("bad signal name '%s'", arg); | 196 | bb_error_msg("bad signal name '%s'", arg); |
193 | return EXIT_FAILURE; | 197 | return EXIT_FAILURE; |
194 | } | 198 | } |
199 | do_it_sooner: | ||
195 | arg = *++argv; | 200 | arg = *++argv; |
196 | 201 | ||
197 | do_it_now: | 202 | do_it_now: |