aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--procps/pstree.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/procps/pstree.c b/procps/pstree.c
index 8ba30795d..ea690a9c8 100644
--- a/procps/pstree.c
+++ b/procps/pstree.c
@@ -34,8 +34,15 @@
34 34
35struct child; 35struct child;
36 36
37#ifdef ENABLE_FEATURE_SHOW_THREADS
38/* For threads, we add {...} around the comm, so we need two extra bytes */
39# define COMM_DISP_LEN (COMM_LEN + 2)
40#else
41# define COMM_DISP_LEN COMM_LEN
42#endif
43
37typedef struct proc { 44typedef struct proc {
38 char comm[COMM_LEN + 1]; 45 char comm[COMM_DISP_LEN + 1];
39// char flags; - unused, delete? 46// char flags; - unused, delete?
40 pid_t pid; 47 pid_t pid;
41 uid_t uid; 48 uid_t uid;
@@ -341,8 +348,8 @@ static void dump_by_user(PROC *current, uid_t uid)
341#if ENABLE_FEATURE_SHOW_THREADS 348#if ENABLE_FEATURE_SHOW_THREADS
342static void handle_thread(const char *comm, pid_t pid, pid_t ppid, uid_t uid) 349static void handle_thread(const char *comm, pid_t pid, pid_t ppid, uid_t uid)
343{ 350{
344 char threadname[COMM_LEN + 2]; 351 char threadname[COMM_DISP_LEN + 1];
345 sprintf(threadname, "{%.*s}", COMM_LEN - 2, comm); 352 sprintf(threadname, "{%.*s}", (int)sizeof(threadname) - 1, comm);
346 add_proc(threadname, pid, ppid, uid/*, 1*/); 353 add_proc(threadname, pid, ppid, uid/*, 1*/);
347} 354}
348#endif 355#endif