From 89e67c6f7a77e0e16cbf394f18d4cb121e37f544 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 29 Aug 2023 14:55:24 +0100 Subject: ps: increase length of 'comm' field In Linux the command name associated with a process (as can be obtained from '/proc//comm') is truncated to 16 characters. Thus upstream BusyBox only allows 16 characters for the 'comm' field in 'ps'. There's no need for such a constraint in busybox-w32. Moreover, the command name is used for the full command line ('args' field) in most cases. This field is allowed to be rather long in 'ps' so it's not expected to be truncated. Still, to avoid diverging too much from upstream it's best to have some measure of truncation. Increase the allowed length of the command name to 32 characters. Adds 16 bytes. (GitHub issue #358) --- include/libbb.h | 4 ++++ procps/ps.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/include/libbb.h b/include/libbb.h index e3b17655c..2cdfac639 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -2088,6 +2088,10 @@ int read_line_input(const char* prompt, char* command, int maxsize) FAST_FUNC; read_line_input(prompt, command, maxsize) #endif +#if ENABLE_PLATFORM_MINGW32 +# undef COMM_LEN +# define COMM_LEN 32 +#endif #ifndef COMM_LEN # ifdef TASK_COMM_LEN enum { COMM_LEN = TASK_COMM_LEN }; diff --git a/procps/ps.c b/procps/ps.c index 823539b9a..329576eb8 100644 --- a/procps/ps.c +++ b/procps/ps.c @@ -383,7 +383,11 @@ static const ps_out_t out_spec[] ALIGN_PTR = { /* Mandated by http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html: */ { 8 , "user" ,"USER" ,func_user ,PSSCAN_UIDGID }, { 8 , "group" ,"GROUP" ,func_group ,PSSCAN_UIDGID }, +#if ENABLE_PLATFORM_MINGW32 + { COMM_LEN , "comm" ,"COMMAND",func_comm ,PSSCAN_COMM }, +#else { 16 , "comm" ,"COMMAND",func_comm ,PSSCAN_COMM }, +#endif { MAX_WIDTH , "args" ,"COMMAND",func_args ,PSSCAN_COMM }, { 5 , "pid" ,"PID" ,func_pid ,PSSCAN_PID }, { 5 , "ppid" ,"PPID" ,func_ppid ,PSSCAN_PPID }, -- cgit v1.2.3-55-g6feb