top: batch mode should output all processes
This commit is contained in:
12
procps/top.c
12
procps/top.c
@ -224,14 +224,12 @@ static unsigned long display_generic(int scr_width)
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
/* read load average as a string */
|
/* read load average as a string */
|
||||||
fp = xfopen("loadavg", "r");
|
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
fgets(buf, sizeof(buf), fp);
|
open_read_close("loadavg", buf, sizeof(buf));
|
||||||
end = strchr(buf, ' ');
|
end = strchr(buf, ' ');
|
||||||
if (end) end = strchr(end+1, ' ');
|
if (end) end = strchr(end+1, ' ');
|
||||||
if (end) end = strchr(end+1, ' ');
|
if (end) end = strchr(end+1, ' ');
|
||||||
if (end) *end = '\0';
|
if (end) *end = '\0';
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
if (needs_conversion) {
|
if (needs_conversion) {
|
||||||
/* convert to kilobytes */
|
/* convert to kilobytes */
|
||||||
@ -253,8 +251,7 @@ static unsigned long display_generic(int scr_width)
|
|||||||
|
|
||||||
printf(OPT_BATCH_MODE ? "%s\n" : "\e[H\e[J%s\n", scrbuf);
|
printf(OPT_BATCH_MODE ? "%s\n" : "\e[H\e[J%s\n", scrbuf);
|
||||||
|
|
||||||
snprintf(scrbuf, scr_width,
|
snprintf(scrbuf, scr_width, "Load average: %s", buf);
|
||||||
"Load average: %s", buf);
|
|
||||||
printf("%s\n", scrbuf);
|
printf("%s\n", scrbuf);
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
@ -321,7 +318,6 @@ static void display_status(int count, int scr_width)
|
|||||||
}
|
}
|
||||||
/* printf(" pmem_scale=%u pcpu_scale=%u ", pmem_scale, pcpu_scale); */
|
/* printf(" pmem_scale=%u pcpu_scale=%u ", pmem_scale, pcpu_scale); */
|
||||||
#endif
|
#endif
|
||||||
if (OPT_BATCH_MODE) count--;
|
|
||||||
while (count-- > 0) {
|
while (count-- > 0) {
|
||||||
div_t pmem = div((s->rss*pmem_scale) >> pmem_shift, 10);
|
div_t pmem = div((s->rss*pmem_scale) >> pmem_shift, 10);
|
||||||
int col = scr_width+1;
|
int col = scr_width+1;
|
||||||
@ -337,7 +333,7 @@ static void display_status(int count, int scr_width)
|
|||||||
s->pid, s->user, s->state, rss_str_buf, s->ppid,
|
s->pid, s->user, s->state, rss_str_buf, s->ppid,
|
||||||
USE_FEATURE_TOP_CPU_USAGE_PERCENTAGE(pcpu.quot, '0'+pcpu.rem,)
|
USE_FEATURE_TOP_CPU_USAGE_PERCENTAGE(pcpu.quot, '0'+pcpu.rem,)
|
||||||
pmem.quot, '0'+pmem.rem);
|
pmem.quot, '0'+pmem.rem);
|
||||||
if (col>0)
|
if (col > 0)
|
||||||
printf("%.*s", col, s->short_cmd);
|
printf("%.*s", col, s->short_cmd);
|
||||||
/* printf(" %d/%d %lld/%lld", s->pcpu, total_pcpu,
|
/* printf(" %d/%d %lld/%lld", s->pcpu, total_pcpu,
|
||||||
jif.busy - prev_jif.busy, jif.total - prev_jif.total); */
|
jif.busy - prev_jif.busy, jif.total - prev_jif.total); */
|
||||||
@ -463,7 +459,7 @@ int top_main(int argc, char **argv)
|
|||||||
qsort(top, ntop, sizeof(procps_status_t), (void*)sort_function);
|
qsort(top, ntop, sizeof(procps_status_t), (void*)sort_function);
|
||||||
#endif /* CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE */
|
#endif /* CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE */
|
||||||
count = lines;
|
count = lines;
|
||||||
if (count > ntop) {
|
if (OPT_BATCH_MODE || count > ntop) {
|
||||||
count = ntop;
|
count = ntop;
|
||||||
}
|
}
|
||||||
/* show status for each of the processes */
|
/* show status for each of the processes */
|
||||||
|
@ -2277,7 +2277,7 @@ add_partition(int n, int sys)
|
|||||||
if (start > limit)
|
if (start > limit)
|
||||||
break;
|
break;
|
||||||
if (start >= temp+units_per_sector && num_read) {
|
if (start >= temp+units_per_sector && num_read) {
|
||||||
printf(_("Sector %llu is already allocated\n"), (unsigned long long)temp);
|
printf(_("Sector "OFF_T_FMT" is already allocated\n"), temp);
|
||||||
temp = start;
|
temp = start;
|
||||||
num_read = 0;
|
num_read = 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user