ps: show longer COMMAND

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2009-10-09 19:47:01 +02:00
parent dea478855f
commit a05b2b856b

View File

@ -303,7 +303,7 @@ static const ps_out_t out_spec[] = {
{ 8 , "user" ,"USER" ,func_user ,PSSCAN_UIDGID }, { 8 , "user" ,"USER" ,func_user ,PSSCAN_UIDGID },
{ 8 , "group" ,"GROUP" ,func_group ,PSSCAN_UIDGID }, { 8 , "group" ,"GROUP" ,func_group ,PSSCAN_UIDGID },
{ 16 , "comm" ,"COMMAND",func_comm ,PSSCAN_COMM }, { 16 , "comm" ,"COMMAND",func_comm ,PSSCAN_COMM },
{ 256 , "args" ,"COMMAND",func_args ,PSSCAN_COMM }, { MAX_WIDTH , "args" ,"COMMAND",func_args ,PSSCAN_COMM },
{ 5 , "pid" ,"PID" ,func_pid ,PSSCAN_PID }, { 5 , "pid" ,"PID" ,func_pid ,PSSCAN_PID },
{ 5 , "ppid" ,"PPID" ,func_ppid ,PSSCAN_PPID }, { 5 , "ppid" ,"PPID" ,func_ppid ,PSSCAN_PPID },
{ 5 , "pgid" ,"PGID" ,func_pgid ,PSSCAN_PGID }, { 5 , "pgid" ,"PGID" ,func_pgid ,PSSCAN_PGID },
@ -383,7 +383,7 @@ static void parse_o(char* opt)
print_header = 1; print_header = 1;
} }
static void post_process(void) static void alloc_line_buffer(void)
{ {
int i; int i;
int width = 0; int width = 0;
@ -393,6 +393,12 @@ static void post_process(void)
print_header = 1; print_header = 1;
} }
width += out[i].width + 1; /* "FIELD " */ width += out[i].width + 1; /* "FIELD " */
if ((int)(width - terminal_width) > 0) {
/* The rest does not fit on the screen */
//out[i].width -= (width - terminal_width - 1);
out_cnt = i + 1;
break;
}
} }
#if ENABLE_SELINUX #if ENABLE_SELINUX
if (!is_selinux_enabled()) if (!is_selinux_enabled())
@ -497,7 +503,6 @@ int ps_main(int argc UNUSED_PARAM, char **argv)
} }
parse_o(default_o); parse_o(default_o);
} }
post_process();
#if ENABLE_FEATURE_SHOW_THREADS #if ENABLE_FEATURE_SHOW_THREADS
if (opt & OPT_T) if (opt & OPT_T)
need_flags |= PSSCAN_TASKS; need_flags |= PSSCAN_TASKS;
@ -511,6 +516,7 @@ int ps_main(int argc UNUSED_PARAM, char **argv)
if (--terminal_width > MAX_WIDTH) if (--terminal_width > MAX_WIDTH)
terminal_width = MAX_WIDTH; terminal_width = MAX_WIDTH;
} }
alloc_line_buffer();
format_header(); format_header();
p = NULL; p = NULL;