aboutsummaryrefslogtreecommitdiff
path: root/procps/kill.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2011-02-21 03:22:20 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2011-02-21 03:22:20 +0100
commitb12553faa8991e11c11f70a81f1d9d44078c7645 (patch)
tree4154d5308a9bad6bb46e2014cb6cc997dc9a92cd /procps/kill.c
parent55988aed472d9cd362f9a50f4999b5e47ca33abe (diff)
downloadbusybox-b12553faa8991e11c11f70a81f1d9d44078c7645.tar.gz
ash: fix ash-signals/signal8 testcase failure
function old new delta killcmd 109 224 +115 kill_main 882 910 +28 changepath 194 195 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 144/0) Total: 144 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'procps/kill.c')
-rw-r--r--procps/kill.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/procps/kill.c b/procps/kill.c
index b51d44a70..39538016e 100644
--- a/procps/kill.c
+++ b/procps/kill.c
@@ -206,9 +206,27 @@ int kill_main(int argc, char **argv)
/* Looks like they want to do a kill. Do that */
while (arg) {
- /* Support shell 'space' trick */
- if (arg[0] == ' ')
- arg++;
+#if ENABLE_ASH || ENABLE_HUSH
+ /*
+ * We need to support shell's "hack formats" of
+ * " -PRGP_ID" (yes, with a leading space)
+ * and " PID1 PID2 PID3" (with degenerate case "")
+ */
+ while (*arg != '\0') {
+ char *end;
+ if (*arg == ' ')
+ arg++;
+ pid = bb_strtoi(arg, &end, 10);
+ if (errno && (errno != EINVAL || *end != ' ')) {
+ bb_error_msg("invalid number '%s'", arg);
+ errors++;
+ } else if (kill(pid, signo) != 0) {
+ bb_perror_msg("can't kill pid %d", (int)pid);
+ errors++;
+ }
+ arg = end; /* can only point to ' ' or '\0' now */
+ }
+#else
pid = bb_strtoi(arg, NULL, 10);
if (errno) {
bb_error_msg("invalid number '%s'", arg);
@@ -217,6 +235,7 @@ int kill_main(int argc, char **argv)
bb_perror_msg("can't kill pid %d", (int)pid);
errors++;
}
+#endif
arg = *++argv;
}
return errors;