Browse Source

Make killall and killall5 selecatable independent from kill

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko 7 years ago
parent
commit
5467d268f0
1 changed files with 16 additions and 8 deletions
  1. 16 8
      procps/kill.c

+ 16 - 8
procps/kill.c

@@ -18,7 +18,6 @@
 //config:config KILLALL
 //config:	bool "killall"
 //config:	default y
-//config:	depends on KILL
 //config:	help
 //config:	  killall sends a signal to all processes running any of the
 //config:	  specified commands. If no signal name is specified, SIGTERM is
@@ -27,8 +26,11 @@
 //config:config KILLALL5
 //config:	bool "killall5"
 //config:	default y
-//config:	depends on KILL
-//config:
+//config:	help
+//config:	  The SystemV killall command. killall5 sends a signal
+//config:	  to all processes except kernel threads and the processes
+//config:	  in its own session, so it won't kill the shell that is running
+//config:	  the script it was called from.
 
 //applet:IF_KILL(APPLET(kill, BB_DIR_BIN, BB_SUID_DROP))
 //applet:IF_KILLALL(APPLET_ODDNAME(killall, kill, BB_DIR_USR_BIN, BB_SUID_DROP, killall))
@@ -95,17 +97,23 @@ int kill_main(int argc UNUSED_PARAM, char **argv)
 	char *arg;
 	pid_t pid;
 	int signo = SIGTERM, errors = 0, quiet = 0;
-#if !ENABLE_KILLALL && !ENABLE_KILLALL5
-#define killall 0
-#define killall5 0
+#if ENABLE_KILL && !ENABLE_KILLALL && !ENABLE_KILLALL5
+# define killall  0
+# define killall5 0
+#elif !ENABLE_KILL && ENABLE_KILLALL && !ENABLE_KILLALL5
+# define killall  1
+# define killall5 0
+#elif !ENABLE_KILL && !ENABLE_KILLALL && ENABLE_KILLALL5
+# define killall  0
+# define killall5 1
 #else
 /* How to determine who we are? find 3rd char from the end:
  * kill, killall, killall5
  *  ^i       ^a        ^l  - it's unique
  * (checking from the start is complicated by /bin/kill... case) */
 	const char char3 = argv[0][strlen(argv[0]) - 3];
-#define killall (ENABLE_KILLALL && char3 == 'a')
-#define killall5 (ENABLE_KILLALL5 && char3 == 'l')
+# define killall  (ENABLE_KILLALL && char3 == 'a')
+# define killall5 (ENABLE_KILLALL5 && char3 == 'l')
 #endif
 
 	/* Parse any options */