aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-01-09 05:47:57 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2017-01-09 05:47:57 +0100
commitfd68f1e80dbed81e42a0298db5fcf578e8d944a9 (patch)
tree80a7416398a5eecb03563cea1fed0bc747a31b64 /shell
parent442a414d66266336e09eae2ea6713b5bf054475e (diff)
downloadbusybox-w32-fd68f1e80dbed81e42a0298db5fcf578e8d944a9.tar.gz
busybox-w32-fd68f1e80dbed81e42a0298db5fcf578e8d944a9.tar.bz2
busybox-w32-fd68f1e80dbed81e42a0298db5fcf578e8d944a9.zip
hush: fix kill builtin without jobs support
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/hush.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 01c334a46..247ad7aab 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -9443,7 +9443,7 @@ static struct pipe *parse_jobspec(const char *str)
9443 return pi; 9443 return pi;
9444 } 9444 }
9445 } 9445 }
9446 bb_error_msg("%d: no such job", jobnum); 9446 bb_error_msg("%u: no such job", jobnum);
9447 return NULL; 9447 return NULL;
9448} 9448}
9449 9449
@@ -9691,9 +9691,9 @@ static int FAST_FUNC builtin_kill(char **argv)
9691{ 9691{
9692 int ret = 0; 9692 int ret = 0;
9693 9693
9694 argv = skip_dash_dash(argv); 9694# if ENABLE_HUSH_JOB
9695 if (argv[0] && strcmp(argv[0], "-l") != 0) { 9695 if (argv[1] && strcmp(argv[1], "-l") != 0) {
9696 int i = 0; 9696 int i = 1;
9697 9697
9698 do { 9698 do {
9699 struct pipe *pi; 9699 struct pipe *pi;
@@ -9735,12 +9735,9 @@ static int FAST_FUNC builtin_kill(char **argv)
9735 n = 1; 9735 n = 1;
9736 dst = alloca(n * sizeof(int)*4); 9736 dst = alloca(n * sizeof(int)*4);
9737 argv[i] = dst; 9737 argv[i] = dst;
9738#if ENABLE_HUSH_JOB
9739 if (G_interactive_fd) 9738 if (G_interactive_fd)
9740 dst += sprintf(dst, " -%u", (int)pi->pgrp); 9739 dst += sprintf(dst, " -%u", (int)pi->pgrp);
9741 else 9740 else for (j = 0; j < n; j++) {
9742#endif
9743 for (j = 0; j < n; j++) {
9744 struct command *cmd = &pi->cmds[j]; 9741 struct command *cmd = &pi->cmds[j];
9745 /* Skip exited members of the job */ 9742 /* Skip exited members of the job */
9746 if (cmd->pid == 0) 9743 if (cmd->pid == 0)
@@ -9755,13 +9752,12 @@ static int FAST_FUNC builtin_kill(char **argv)
9755 *dst = '\0'; 9752 *dst = '\0';
9756 } while (argv[++i]); 9753 } while (argv[++i]);
9757 } 9754 }
9755# endif
9758 9756
9759 if (argv[0] || ret == 0) { 9757 if (argv[1] || ret == 0) {
9760 argv--;
9761 argv[0] = (char*)"kill"; /* why? think about "kill -- PID" */
9762 /* kill_main also handles "killall" etc, so it does look at argv[0]! */
9763 ret = run_applet_main(argv, kill_main); 9758 ret = run_applet_main(argv, kill_main);
9764 } 9759 }
9760 /* else: ret = 1, "kill %bad_jobspec" case */
9765 return ret; 9761 return ret;
9766} 9762}
9767#endif 9763#endif