diff options
Diffstat (limited to 'procps')
-rw-r--r-- | procps/top.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/procps/top.c b/procps/top.c index bff9f7c4f..96b3e2d4e 100644 --- a/procps/top.c +++ b/procps/top.c | |||
@@ -602,6 +602,15 @@ static void parse_meminfo(unsigned long meminfo[MI_MAX]) | |||
602 | fclose(f); | 602 | fclose(f); |
603 | } | 603 | } |
604 | 604 | ||
605 | static void cmdline_to_line_buf_and_print(unsigned offset, unsigned pid, const char *comm) | ||
606 | { | ||
607 | int width = G.scr_width - offset; | ||
608 | if (width > 1) /* wider than to fit just the NUL? */ | ||
609 | read_cmdline(G.line_buf + offset, width, pid, comm); | ||
610 | //TODO: read_cmdline() sanitizes control chars, but not chars above 0x7e | ||
611 | print_line_buf(); | ||
612 | } | ||
613 | |||
605 | static unsigned long display_header(void) | 614 | static unsigned long display_header(void) |
606 | { | 615 | { |
607 | char *buf; | 616 | char *buf; |
@@ -789,9 +798,7 @@ static NOINLINE void display_process_list(void) | |||
789 | IF_FEATURE_TOP_SMP_PROCESS(, s->last_seen_on_cpu) | 798 | IF_FEATURE_TOP_SMP_PROCESS(, s->last_seen_on_cpu) |
790 | IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(, SHOW_STAT(pcpu)) | 799 | IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(, SHOW_STAT(pcpu)) |
791 | ); | 800 | ); |
792 | if ((int)(G.scr_width - col) > 1) | 801 | cmdline_to_line_buf_and_print(col, s->pid, s->comm); |
793 | read_cmdline(G.line_buf + col, G.scr_width - col, s->pid, s->comm); | ||
794 | print_line_buf(); | ||
795 | /* printf(" %d/%d %lld/%lld", s->pcpu, total_pcpu, | 802 | /* printf(" %d/%d %lld/%lld", s->pcpu, total_pcpu, |
796 | cur_jif.busy - prev_jif.busy, cur_jif.total - prev_jif.total); */ | 803 | cur_jif.busy - prev_jif.busy, cur_jif.total - prev_jif.total); */ |
797 | s++; | 804 | s++; |
@@ -910,14 +917,12 @@ static void ulltoa4_and_space(unsigned long long ul, char buf[5]) | |||
910 | 917 | ||
911 | static NOINLINE void display_topmem_process_list(void) | 918 | static NOINLINE void display_topmem_process_list(void) |
912 | { | 919 | { |
913 | #define HDR_STR " PID VSZ VSZRW RSS (SHR) DIRTY (SHR) STACK" | ||
914 | #define MIN_WIDTH sizeof(HDR_STR) | ||
915 | const topmem_status_t *s = topmem + G_scroll_ofs; | 920 | const topmem_status_t *s = topmem + G_scroll_ofs; |
916 | char *cp, ch; | 921 | char *cp, ch; |
917 | 922 | ||
918 | display_topmem_header(); | 923 | display_topmem_header(); |
919 | 924 | ||
920 | strcpy(G.line_buf, HDR_STR " COMMAND"); | 925 | strcpy(G.line_buf, " PID VSZ VSZRW RSS (SHR) DIRTY (SHR) STACK COMMAND"); |
921 | /* Mark the ^FIELD^ we sort by */ | 926 | /* Mark the ^FIELD^ we sort by */ |
922 | cp = &G.line_buf[5 + sort_field * 6]; | 927 | cp = &G.line_buf[5 + sort_field * 6]; |
923 | ch = "^_"[inverted]; | 928 | ch = "^_"[inverted]; |
@@ -949,13 +954,9 @@ static NOINLINE void display_topmem_process_list(void) | |||
949 | ulltoa5_and_space(s->dirty_sh, &G.line_buf[6*6]); | 954 | ulltoa5_and_space(s->dirty_sh, &G.line_buf[6*6]); |
950 | ulltoa5_and_space(s->stack , &G.line_buf[7*6]); | 955 | ulltoa5_and_space(s->stack , &G.line_buf[7*6]); |
951 | G.line_buf[8*6] = '\0'; | 956 | G.line_buf[8*6] = '\0'; |
952 | if ((int)(G.scr_width - MIN_WIDTH) > 1) | 957 | cmdline_to_line_buf_and_print(8*6, s->pid, s->comm); |
953 | read_cmdline(&G.line_buf[8*6], G.scr_width - MIN_WIDTH, s->pid, s->comm); | ||
954 | print_line_buf(); | ||
955 | s++; | 958 | s++; |
956 | } | 959 | } |
957 | #undef HDR_STR | ||
958 | #undef MIN_WIDTH | ||
959 | } | 960 | } |
960 | 961 | ||
961 | #endif /* end TOPMEM support */ | 962 | #endif /* end TOPMEM support */ |