ps: show longer COMMAND
authorDenys Vlasenko <vda.linux@googlemail.com>
Fri, 9 Oct 2009 17:47:01 +0000 (19:47 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 9 Oct 2009 17:47:01 +0000 (19:47 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
procps/ps.c

index d86ac6d2f48d32050a7e429ce08b94785a87b247..e94004541677b39180543af40268fc093ef319f4 100644 (file)
@@ -303,7 +303,7 @@ static const ps_out_t out_spec[] = {
        { 8                  , "user"  ,"USER"   ,func_user  ,PSSCAN_UIDGID  },
        { 8                  , "group" ,"GROUP"  ,func_group ,PSSCAN_UIDGID  },
        { 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                  , "ppid"  ,"PPID"   ,func_ppid  ,PSSCAN_PPID    },
        { 5                  , "pgid"  ,"PGID"   ,func_pgid  ,PSSCAN_PGID    },
@@ -383,7 +383,7 @@ static void parse_o(char* opt)
                print_header = 1;
 }
 
-static void post_process(void)
+static void alloc_line_buffer(void)
 {
        int i;
        int width = 0;
@@ -393,6 +393,12 @@ static void post_process(void)
                        print_header = 1;
                }
                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 (!is_selinux_enabled())
@@ -497,7 +503,6 @@ int ps_main(int argc UNUSED_PARAM, char **argv)
                }
                parse_o(default_o);
        }
-       post_process();
 #if ENABLE_FEATURE_SHOW_THREADS
        if (opt & OPT_T)
                need_flags |= PSSCAN_TASKS;
@@ -511,6 +516,7 @@ int ps_main(int argc UNUSED_PARAM, char **argv)
                if (--terminal_width > MAX_WIDTH)
                        terminal_width = MAX_WIDTH;
        }
+       alloc_line_buffer();
        format_header();
 
        p = NULL;