diff options
author | Ron Yorston <rmy@pobox.com> | 2014-01-02 10:25:11 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2014-01-02 10:25:11 +0000 |
commit | b8f278ee745778806118f57fb7884d205eba05ad (patch) | |
tree | fef237f6dd302c59918cf389a60c120e58d3e086 /procps | |
parent | 3fd34651ea72ea1c335d3170f234cb0517fd897f (diff) | |
parent | 57434022cefde87133b8ad39fb3b79c1274e7684 (diff) | |
download | busybox-w32-b8f278ee745778806118f57fb7884d205eba05ad.tar.gz busybox-w32-b8f278ee745778806118f57fb7884d205eba05ad.tar.bz2 busybox-w32-b8f278ee745778806118f57fb7884d205eba05ad.zip |
Merge branch 'busybox' into merge
Conflicts:
archival/Config.src
shell/ash.c
Diffstat (limited to 'procps')
-rw-r--r-- | procps/kill.c | 43 | ||||
-rw-r--r-- | procps/nmeter.c | 3 | ||||
-rw-r--r-- | procps/pgrep.c | 4 | ||||
-rw-r--r-- | procps/powertop.c | 3 | ||||
-rw-r--r-- | procps/ps.c | 9 | ||||
-rw-r--r-- | procps/top.c | 5 |
6 files changed, 31 insertions, 36 deletions
diff --git a/procps/kill.c b/procps/kill.c index cd189bcd6..c5c7a8d72 100644 --- a/procps/kill.c +++ b/procps/kill.c | |||
@@ -60,7 +60,7 @@ | |||
60 | * This is needed to avoid collision with kill -9 ... syntax | 60 | * This is needed to avoid collision with kill -9 ... syntax |
61 | */ | 61 | */ |
62 | 62 | ||
63 | int kill_main(int argc, char **argv) | 63 | int kill_main(int argc UNUSED_PARAM, char **argv) |
64 | { | 64 | { |
65 | char *arg; | 65 | char *arg; |
66 | pid_t pid; | 66 | pid_t pid; |
@@ -79,10 +79,9 @@ int kill_main(int argc, char **argv) | |||
79 | #endif | 79 | #endif |
80 | 80 | ||
81 | /* Parse any options */ | 81 | /* Parse any options */ |
82 | argc--; | ||
83 | arg = *++argv; | 82 | arg = *++argv; |
84 | 83 | ||
85 | if (argc < 1 || arg[0] != '-') { | 84 | if (!arg || arg[0] != '-') { |
86 | goto do_it_now; | 85 | goto do_it_now; |
87 | } | 86 | } |
88 | 87 | ||
@@ -91,13 +90,14 @@ int kill_main(int argc, char **argv) | |||
91 | * echo "Died of SIG`kill -l $?`" | 90 | * echo "Died of SIG`kill -l $?`" |
92 | * We try to mimic what kill from coreutils-6.8 does */ | 91 | * We try to mimic what kill from coreutils-6.8 does */ |
93 | if (arg[1] == 'l' && arg[2] == '\0') { | 92 | if (arg[1] == 'l' && arg[2] == '\0') { |
94 | if (argc == 1) { | 93 | arg = *++argv; |
94 | if (!arg) { | ||
95 | /* Print the whole signal list */ | 95 | /* Print the whole signal list */ |
96 | print_signames(); | 96 | print_signames(); |
97 | return 0; | 97 | return 0; |
98 | } | 98 | } |
99 | /* -l <sig list> */ | 99 | /* -l <sig list> */ |
100 | while ((arg = *++argv)) { | 100 | do { |
101 | if (isdigit(arg[0])) { | 101 | if (isdigit(arg[0])) { |
102 | signo = bb_strtou(arg, NULL, 10); | 102 | signo = bb_strtou(arg, NULL, 10); |
103 | if (errno) { | 103 | if (errno) { |
@@ -118,8 +118,8 @@ int kill_main(int argc, char **argv) | |||
118 | } | 118 | } |
119 | printf("%d\n", signo); | 119 | printf("%d\n", signo); |
120 | } | 120 | } |
121 | } | 121 | arg = *++argv; |
122 | /* If they specified -l, we are all done */ | 122 | } while (arg); |
123 | return EXIT_SUCCESS; | 123 | return EXIT_SUCCESS; |
124 | } | 124 | } |
125 | 125 | ||
@@ -127,8 +127,7 @@ int kill_main(int argc, char **argv) | |||
127 | if (killall && arg[1] == 'q' && arg[2] == '\0') { | 127 | if (killall && arg[1] == 'q' && arg[2] == '\0') { |
128 | quiet = 1; | 128 | quiet = 1; |
129 | arg = *++argv; | 129 | arg = *++argv; |
130 | argc--; | 130 | if (!arg) |
131 | if (argc < 1) | ||
132 | bb_show_usage(); | 131 | bb_show_usage(); |
133 | if (arg[0] != '-') | 132 | if (arg[0] != '-') |
134 | goto do_it_now; | 133 | goto do_it_now; |
@@ -140,8 +139,7 @@ int kill_main(int argc, char **argv) | |||
140 | if (killall5 && arg[0] == 'o') | 139 | if (killall5 && arg[0] == 'o') |
141 | goto do_it_now; | 140 | goto do_it_now; |
142 | 141 | ||
143 | if (argc > 1 && arg[0] == 's' && arg[1] == '\0') { /* -s SIG? */ | 142 | if (argv[1] && arg[0] == 's' && arg[1] == '\0') { /* -s SIG? */ |
144 | argc--; | ||
145 | arg = *++argv; | 143 | arg = *++argv; |
146 | } /* else it must be -SIG */ | 144 | } /* else it must be -SIG */ |
147 | signo = get_signum(arg); | 145 | signo = get_signum(arg); |
@@ -150,7 +148,6 @@ int kill_main(int argc, char **argv) | |||
150 | return EXIT_FAILURE; | 148 | return EXIT_FAILURE; |
151 | } | 149 | } |
152 | arg = *++argv; | 150 | arg = *++argv; |
153 | argc--; | ||
154 | 151 | ||
155 | do_it_now: | 152 | do_it_now: |
156 | pid = getpid(); | 153 | pid = getpid(); |
@@ -158,7 +155,8 @@ int kill_main(int argc, char **argv) | |||
158 | if (killall5) { | 155 | if (killall5) { |
159 | pid_t sid; | 156 | pid_t sid; |
160 | procps_status_t* p = NULL; | 157 | procps_status_t* p = NULL; |
161 | int ret = 0; | 158 | /* compat: exitcode 2 is "no one was signaled" */ |
159 | int ret = 2; | ||
162 | 160 | ||
163 | /* Find out our session id */ | 161 | /* Find out our session id */ |
164 | sid = getsid(pid); | 162 | sid = getsid(pid); |
@@ -167,9 +165,10 @@ int kill_main(int argc, char **argv) | |||
167 | kill(-1, SIGSTOP); | 165 | kill(-1, SIGSTOP); |
168 | /* Signal all processes except those in our session */ | 166 | /* Signal all processes except those in our session */ |
169 | while ((p = procps_scan(p, PSSCAN_PID|PSSCAN_SID)) != NULL) { | 167 | while ((p = procps_scan(p, PSSCAN_PID|PSSCAN_SID)) != NULL) { |
170 | int i; | 168 | char **args; |
171 | 169 | ||
172 | if (p->sid == (unsigned)sid | 170 | if (p->sid == (unsigned)sid |
171 | || p->sid == 0 /* compat: kernel thread, don't signal it */ | ||
173 | || p->pid == (unsigned)pid | 172 | || p->pid == (unsigned)pid |
174 | || p->pid == 1 | 173 | || p->pid == 1 |
175 | ) { | 174 | ) { |
@@ -178,18 +177,19 @@ int kill_main(int argc, char **argv) | |||
178 | 177 | ||
179 | /* All remaining args must be -o PID options. | 178 | /* All remaining args must be -o PID options. |
180 | * Check p->pid against them. */ | 179 | * Check p->pid against them. */ |
181 | for (i = 0; i < argc; i++) { | 180 | args = argv; |
181 | while (*args) { | ||
182 | pid_t omit; | 182 | pid_t omit; |
183 | 183 | ||
184 | arg = argv[i]; | 184 | arg = *args++; |
185 | if (arg[0] != '-' || arg[1] != 'o') { | 185 | if (arg[0] != '-' || arg[1] != 'o') { |
186 | bb_error_msg("bad option '%s'", arg); | 186 | bb_error_msg("bad option '%s'", arg); |
187 | ret = 1; | 187 | ret = 1; |
188 | goto resume; | 188 | goto resume; |
189 | } | 189 | } |
190 | arg += 2; | 190 | arg += 2; |
191 | if (!arg[0] && argv[++i]) | 191 | if (!arg[0] && *args) |
192 | arg = argv[i]; | 192 | arg = *args++; |
193 | omit = bb_strtoi(arg, NULL, 10); | 193 | omit = bb_strtoi(arg, NULL, 10); |
194 | if (errno) { | 194 | if (errno) { |
195 | bb_error_msg("invalid number '%s'", arg); | 195 | bb_error_msg("invalid number '%s'", arg); |
@@ -200,6 +200,7 @@ int kill_main(int argc, char **argv) | |||
200 | goto dont_kill; | 200 | goto dont_kill; |
201 | } | 201 | } |
202 | kill(p->pid, signo); | 202 | kill(p->pid, signo); |
203 | ret = 0; | ||
203 | dont_kill: ; | 204 | dont_kill: ; |
204 | } | 205 | } |
205 | resume: | 206 | resume: |
@@ -210,14 +211,14 @@ int kill_main(int argc, char **argv) | |||
210 | } | 211 | } |
211 | 212 | ||
212 | /* Pid or name is required for kill/killall */ | 213 | /* Pid or name is required for kill/killall */ |
213 | if (argc < 1) { | 214 | if (!arg) { |
214 | bb_error_msg("you need to specify whom to kill"); | 215 | bb_error_msg("you need to specify whom to kill"); |
215 | return EXIT_FAILURE; | 216 | return EXIT_FAILURE; |
216 | } | 217 | } |
217 | 218 | ||
218 | if (killall) { | 219 | if (killall) { |
219 | /* Looks like they want to do a killall. Do that */ | 220 | /* Looks like they want to do a killall. Do that */ |
220 | while (arg) { | 221 | do { |
221 | pid_t* pidList; | 222 | pid_t* pidList; |
222 | 223 | ||
223 | pidList = find_pid_by_name(arg); | 224 | pidList = find_pid_by_name(arg); |
@@ -240,7 +241,7 @@ int kill_main(int argc, char **argv) | |||
240 | } | 241 | } |
241 | free(pidList); | 242 | free(pidList); |
242 | arg = *++argv; | 243 | arg = *++argv; |
243 | } | 244 | } while (arg); |
244 | return errors; | 245 | return errors; |
245 | } | 246 | } |
246 | 247 | ||
diff --git a/procps/nmeter.c b/procps/nmeter.c index 6a3b32743..5d5b83b8d 100644 --- a/procps/nmeter.c +++ b/procps/nmeter.c | |||
@@ -333,8 +333,7 @@ static void scale(ullong ul) | |||
333 | char buf[5]; | 333 | char buf[5]; |
334 | 334 | ||
335 | /* see http://en.wikipedia.org/wiki/Tera */ | 335 | /* see http://en.wikipedia.org/wiki/Tera */ |
336 | smart_ulltoa4(ul, buf, " kmgtpezy"); | 336 | smart_ulltoa4(ul, buf, " kmgtpezy")[0] = '\0'; |
337 | buf[4] = '\0'; | ||
338 | put(buf); | 337 | put(buf); |
339 | } | 338 | } |
340 | 339 | ||
diff --git a/procps/pgrep.c b/procps/pgrep.c index 8daf5b28a..1c7c7c48b 100644 --- a/procps/pgrep.c +++ b/procps/pgrep.c | |||
@@ -65,9 +65,9 @@ static void act(unsigned pid, char *cmd, int signo) | |||
65 | { | 65 | { |
66 | if (pgrep) { | 66 | if (pgrep) { |
67 | if (option_mask32 & (1 << OPTBIT_L)) /* OPT_LIST */ | 67 | if (option_mask32 & (1 << OPTBIT_L)) /* OPT_LIST */ |
68 | printf("%d %s\n", pid, cmd); | 68 | printf("%u %s\n", pid, cmd); |
69 | else | 69 | else |
70 | printf("%d\n", pid); | 70 | printf("%u\n", pid); |
71 | } else | 71 | } else |
72 | kill(pid, signo); | 72 | kill(pid, signo); |
73 | } | 73 | } |
diff --git a/procps/powertop.c b/procps/powertop.c index 71988a295..e3c29d1c3 100644 --- a/procps/powertop.c +++ b/procps/powertop.c | |||
@@ -627,7 +627,6 @@ static void show_timerstats(void) | |||
627 | int i, n = 0; | 627 | int i, n = 0; |
628 | char strbuf6[6]; | 628 | char strbuf6[6]; |
629 | 629 | ||
630 | strbuf6[5] = '\0'; | ||
631 | puts("\nTop causes for wakeups:"); | 630 | puts("\nTop causes for wakeups:"); |
632 | for (i = 0; i < G.lines_cnt; i++) { | 631 | for (i = 0; i < G.lines_cnt; i++) { |
633 | if ((G.lines[i].count > 0 /*|| G.lines[i].disk_count > 0*/) | 632 | if ((G.lines[i].count > 0 /*|| G.lines[i].disk_count > 0*/) |
@@ -639,7 +638,7 @@ static void show_timerstats(void) | |||
639 | /*char c = ' '; | 638 | /*char c = ' '; |
640 | if (G.lines[i].disk_count) | 639 | if (G.lines[i].disk_count) |
641 | c = 'D';*/ | 640 | c = 'D';*/ |
642 | smart_ulltoa5(G.lines[i].count, strbuf6, " KMGTPEZY"); | 641 | smart_ulltoa5(G.lines[i].count, strbuf6, " KMGTPEZY")[0] = '\0'; |
643 | printf(/*" %5.1f%% (%s)%c %s\n"*/ | 642 | printf(/*" %5.1f%% (%s)%c %s\n"*/ |
644 | " %5.1f%% (%s) %s\n", | 643 | " %5.1f%% (%s) %s\n", |
645 | G.lines[i].count * 100.0 / G.lines_cumulative_count, | 644 | G.lines[i].count * 100.0 / G.lines_cumulative_count, |
diff --git a/procps/ps.c b/procps/ps.c index 0dfda2039..32563776d 100644 --- a/procps/ps.c +++ b/procps/ps.c | |||
@@ -299,8 +299,7 @@ static void put_lu(char *buf, int size, unsigned long u) | |||
299 | char buf4[5]; | 299 | char buf4[5]; |
300 | 300 | ||
301 | /* see http://en.wikipedia.org/wiki/Tera */ | 301 | /* see http://en.wikipedia.org/wiki/Tera */ |
302 | smart_ulltoa4(u, buf4, " mgtpezy"); | 302 | smart_ulltoa4(u, buf4, " mgtpezy")[0] = '\0'; |
303 | buf4[4] = '\0'; | ||
304 | sprintf(buf, "%.*s", size, buf4); | 303 | sprintf(buf, "%.*s", size, buf4); |
305 | } | 304 | } |
306 | 305 | ||
@@ -750,8 +749,7 @@ int ps_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
750 | #endif | 749 | #endif |
751 | { | 750 | { |
752 | char buf6[6]; | 751 | char buf6[6]; |
753 | smart_ulltoa5(p->vsz, buf6, " mgtpezy"); | 752 | smart_ulltoa5(p->vsz, buf6, " mgtpezy")[0] = '\0'; |
754 | buf6[5] = '\0'; | ||
755 | #if ENABLE_FEATURE_PS_LONG | 753 | #if ENABLE_FEATURE_PS_LONG |
756 | if (opts & OPT_l) { | 754 | if (opts & OPT_l) { |
757 | char bufr[6], stime_str[6]; | 755 | char bufr[6], stime_str[6]; |
@@ -762,8 +760,7 @@ int ps_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
762 | time_t start = now - elapsed; | 760 | time_t start = now - elapsed; |
763 | struct tm *tm = localtime(&start); | 761 | struct tm *tm = localtime(&start); |
764 | 762 | ||
765 | smart_ulltoa5(p->rss, bufr, " mgtpezy"); | 763 | smart_ulltoa5(p->rss, bufr, " mgtpezy")[0] = '\0'; |
766 | bufr[5] = '\0'; | ||
767 | 764 | ||
768 | if (p->tty_major == 136) | 765 | if (p->tty_major == 136) |
769 | /* It should be pts/N, not ptsN, but N > 9 | 766 | /* It should be pts/N, not ptsN, but N > 9 |
diff --git a/procps/top.c b/procps/top.c index abee69806..51f1c1aed 100644 --- a/procps/top.c +++ b/procps/top.c | |||
@@ -677,7 +677,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) | |||
677 | if (s->vsz >= 100000) | 677 | if (s->vsz >= 100000) |
678 | sprintf(vsz_str_buf, "%6ldm", s->vsz/1024); | 678 | sprintf(vsz_str_buf, "%6ldm", s->vsz/1024); |
679 | else | 679 | else |
680 | sprintf(vsz_str_buf, "%7ld", s->vsz); | 680 | sprintf(vsz_str_buf, "%7lu", s->vsz); |
681 | /* PID PPID USER STAT VSZ %VSZ [%CPU] COMMAND */ | 681 | /* PID PPID USER STAT VSZ %VSZ [%CPU] COMMAND */ |
682 | col = snprintf(line_buf, scr_width, | 682 | col = snprintf(line_buf, scr_width, |
683 | "\n" "%5u%6u %-8.8s %s%s" FMT | 683 | "\n" "%5u%6u %-8.8s %s%s" FMT |
@@ -847,8 +847,7 @@ static void display_topmem_header(int scr_width, int *lines_rem_p) | |||
847 | static void ulltoa6_and_space(unsigned long long ul, char buf[6]) | 847 | static void ulltoa6_and_space(unsigned long long ul, char buf[6]) |
848 | { | 848 | { |
849 | /* see http://en.wikipedia.org/wiki/Tera */ | 849 | /* see http://en.wikipedia.org/wiki/Tera */ |
850 | smart_ulltoa5(ul, buf, " mgtpezy"); | 850 | smart_ulltoa5(ul, buf, " mgtpezy")[0] = ' '; |
851 | buf[5] = ' '; | ||
852 | } | 851 | } |
853 | 852 | ||
854 | static NOINLINE void display_topmem_process_list(int lines_rem, int scr_width) | 853 | static NOINLINE void display_topmem_process_list(int lines_rem, int scr_width) |