diff options
Diffstat (limited to 'procps/kill.c')
-rw-r--r-- | procps/kill.c | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/procps/kill.c b/procps/kill.c index c5c7a8d72..57a33bcaa 100644 --- a/procps/kill.c +++ b/procps/kill.c | |||
@@ -7,6 +7,38 @@ | |||
7 | * | 7 | * |
8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
9 | */ | 9 | */ |
10 | //config:config KILL | ||
11 | //config: bool "kill" | ||
12 | //config: default y | ||
13 | //config: help | ||
14 | //config: The command kill sends the specified signal to the specified | ||
15 | //config: process or process group. If no signal is specified, the TERM | ||
16 | //config: signal is sent. | ||
17 | //config: | ||
18 | //config:config KILLALL | ||
19 | //config: bool "killall" | ||
20 | //config: default y | ||
21 | //config: help | ||
22 | //config: killall sends a signal to all processes running any of the | ||
23 | //config: specified commands. If no signal name is specified, SIGTERM is | ||
24 | //config: sent. | ||
25 | //config: | ||
26 | //config:config KILLALL5 | ||
27 | //config: bool "killall5" | ||
28 | //config: default y | ||
29 | //config: help | ||
30 | //config: The SystemV killall command. killall5 sends a signal | ||
31 | //config: to all processes except kernel threads and the processes | ||
32 | //config: in its own session, so it won't kill the shell that is running | ||
33 | //config: the script it was called from. | ||
34 | |||
35 | //applet:IF_KILL(APPLET(kill, BB_DIR_BIN, BB_SUID_DROP)) | ||
36 | //applet:IF_KILLALL(APPLET_ODDNAME(killall, kill, BB_DIR_USR_BIN, BB_SUID_DROP, killall)) | ||
37 | //applet:IF_KILLALL5(APPLET_ODDNAME(killall5, kill, BB_DIR_USR_SBIN, BB_SUID_DROP, killall5)) | ||
38 | |||
39 | //kbuild:lib-$(CONFIG_KILL) += kill.o | ||
40 | //kbuild:lib-$(CONFIG_KILLALL) += kill.o | ||
41 | //kbuild:lib-$(CONFIG_KILLALL5) += kill.o | ||
10 | 42 | ||
11 | //usage:#define kill_trivial_usage | 43 | //usage:#define kill_trivial_usage |
12 | //usage: "[-l] [-SIG] PID..." | 44 | //usage: "[-l] [-SIG] PID..." |
@@ -65,17 +97,23 @@ int kill_main(int argc UNUSED_PARAM, char **argv) | |||
65 | char *arg; | 97 | char *arg; |
66 | pid_t pid; | 98 | pid_t pid; |
67 | int signo = SIGTERM, errors = 0, quiet = 0; | 99 | int signo = SIGTERM, errors = 0, quiet = 0; |
68 | #if !ENABLE_KILLALL && !ENABLE_KILLALL5 | 100 | #if ENABLE_KILL && !ENABLE_KILLALL && !ENABLE_KILLALL5 |
69 | #define killall 0 | 101 | # define killall 0 |
70 | #define killall5 0 | 102 | # define killall5 0 |
103 | #elif !ENABLE_KILL && ENABLE_KILLALL && !ENABLE_KILLALL5 | ||
104 | # define killall 1 | ||
105 | # define killall5 0 | ||
106 | #elif !ENABLE_KILL && !ENABLE_KILLALL && ENABLE_KILLALL5 | ||
107 | # define killall 0 | ||
108 | # define killall5 1 | ||
71 | #else | 109 | #else |
72 | /* How to determine who we are? find 3rd char from the end: | 110 | /* How to determine who we are? find 3rd char from the end: |
73 | * kill, killall, killall5 | 111 | * kill, killall, killall5 |
74 | * ^i ^a ^l - it's unique | 112 | * ^i ^a ^l - it's unique |
75 | * (checking from the start is complicated by /bin/kill... case) */ | 113 | * (checking from the start is complicated by /bin/kill... case) */ |
76 | const char char3 = argv[0][strlen(argv[0]) - 3]; | 114 | const char char3 = argv[0][strlen(argv[0]) - 3]; |
77 | #define killall (ENABLE_KILLALL && char3 == 'a') | 115 | # define killall (ENABLE_KILLALL && char3 == 'a') |
78 | #define killall5 (ENABLE_KILLALL5 && char3 == 'l') | 116 | # define killall5 (ENABLE_KILLALL5 && char3 == 'l') |
79 | #endif | 117 | #endif |
80 | 118 | ||
81 | /* Parse any options */ | 119 | /* Parse any options */ |