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>
diff --git a/procps/kill.c b/procps/kill.c
index b51d44a..3953801 100644
--- a/procps/kill.c
+++ b/procps/kill.c
@@ -206,9 +206,27 @@
/* 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 @@
bb_perror_msg("can't kill pid %d", (int)pid);
errors++;
}
+#endif
arg = *++argv;
}
return errors;