aboutsummaryrefslogtreecommitdiff
path: root/procps/top.c
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-10-27 09:34:22 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-10-27 09:34:22 +0000
commit5715cdd71fcb4e5d1b817704c4e421b74eac672a (patch)
treeddac563b48f199d0b3460621dd16626c1d69dee5 /procps/top.c
parentb02bc331a778460854fd78693174e61192e36a22 (diff)
downloadbusybox-w32-5715cdd71fcb4e5d1b817704c4e421b74eac672a.tar.gz
busybox-w32-5715cdd71fcb4e5d1b817704c4e421b74eac672a.tar.bz2
busybox-w32-5715cdd71fcb4e5d1b817704c4e421b74eac672a.zip
top: batch mode should output all processes
git-svn-id: svn://busybox.net/trunk/busybox@16455 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'procps/top.c')
-rw-r--r--procps/top.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/procps/top.c b/procps/top.c
index 06a84c90c..d58fdda97 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -224,14 +224,12 @@ static unsigned long display_generic(int scr_width)
224 fclose(fp); 224 fclose(fp);
225 225
226 /* read load average as a string */ 226 /* read load average as a string */
227 fp = xfopen("loadavg", "r");
228 buf[0] = '\0'; 227 buf[0] = '\0';
229 fgets(buf, sizeof(buf), fp); 228 open_read_close("loadavg", buf, sizeof(buf));
230 end = strchr(buf, ' '); 229 end = strchr(buf, ' ');
231 if (end) end = strchr(end+1, ' '); 230 if (end) end = strchr(end+1, ' ');
232 if (end) end = strchr(end+1, ' '); 231 if (end) end = strchr(end+1, ' ');
233 if (end) *end = '\0'; 232 if (end) *end = '\0';
234 fclose(fp);
235 233
236 if (needs_conversion) { 234 if (needs_conversion) {
237 /* convert to kilobytes */ 235 /* convert to kilobytes */
@@ -253,8 +251,7 @@ static unsigned long display_generic(int scr_width)
253 251
254 printf(OPT_BATCH_MODE ? "%s\n" : "\e[H\e[J%s\n", scrbuf); 252 printf(OPT_BATCH_MODE ? "%s\n" : "\e[H\e[J%s\n", scrbuf);
255 253
256 snprintf(scrbuf, scr_width, 254 snprintf(scrbuf, scr_width, "Load average: %s", buf);
257 "Load average: %s", buf);
258 printf("%s\n", scrbuf); 255 printf("%s\n", scrbuf);
259 256
260 return total; 257 return total;
@@ -321,7 +318,6 @@ static void display_status(int count, int scr_width)
321 } 318 }
322 /* printf(" pmem_scale=%u pcpu_scale=%u ", pmem_scale, pcpu_scale); */ 319 /* printf(" pmem_scale=%u pcpu_scale=%u ", pmem_scale, pcpu_scale); */
323#endif 320#endif
324 if (OPT_BATCH_MODE) count--;
325 while (count-- > 0) { 321 while (count-- > 0) {
326 div_t pmem = div((s->rss*pmem_scale) >> pmem_shift, 10); 322 div_t pmem = div((s->rss*pmem_scale) >> pmem_shift, 10);
327 int col = scr_width+1; 323 int col = scr_width+1;
@@ -337,7 +333,7 @@ static void display_status(int count, int scr_width)
337 s->pid, s->user, s->state, rss_str_buf, s->ppid, 333 s->pid, s->user, s->state, rss_str_buf, s->ppid,
338 USE_FEATURE_TOP_CPU_USAGE_PERCENTAGE(pcpu.quot, '0'+pcpu.rem,) 334 USE_FEATURE_TOP_CPU_USAGE_PERCENTAGE(pcpu.quot, '0'+pcpu.rem,)
339 pmem.quot, '0'+pmem.rem); 335 pmem.quot, '0'+pmem.rem);
340 if (col>0) 336 if (col > 0)
341 printf("%.*s", col, s->short_cmd); 337 printf("%.*s", col, s->short_cmd);
342 /* printf(" %d/%d %lld/%lld", s->pcpu, total_pcpu, 338 /* printf(" %d/%d %lld/%lld", s->pcpu, total_pcpu,
343 jif.busy - prev_jif.busy, jif.total - prev_jif.total); */ 339 jif.busy - prev_jif.busy, jif.total - prev_jif.total); */
@@ -463,7 +459,7 @@ int top_main(int argc, char **argv)
463 qsort(top, ntop, sizeof(procps_status_t), (void*)sort_function); 459 qsort(top, ntop, sizeof(procps_status_t), (void*)sort_function);
464#endif /* CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE */ 460#endif /* CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE */
465 count = lines; 461 count = lines;
466 if (count > ntop) { 462 if (OPT_BATCH_MODE || count > ntop) {
467 count = ntop; 463 count = ntop;
468 } 464 }
469 /* show status for each of the processes */ 465 /* show status for each of the processes */