Truncated thread names in pstree
Dag Wieers
dag at wieers.com
Sun Jun 2 18:46:13 UTC 2013
On Fri, 31 May 2013, Mike Frysinger wrote:
> On Friday 31 May 2013 20:34:16 Dag Wieers wrote:
>> --- busybox-1.21.0/procps/pstree.c.orig 2013-06-01 02:27:14.008530872 +0200
>> +++ busybox-1.21.0/procps/pstree.c 2013-06-01 02:31:36.483537110 +0200
>> @@ -342,7 +342,7 @@
>> static void handle_thread(const char *comm, pid_t pid, pid_t ppid, uid_t
>> uid) {
>> char threadname[COMM_LEN + 2];
>> - sprintf(threadname, "{%.*s}", COMM_LEN - 2, comm);
>> + sprintf(threadname, "{%.*s}", COMM_LEN - 1, comm);
>> add_proc(threadname, pid, ppid, uid/*, 1*/);
>> }
>
> hmm, your change is correct all by itself (but really it should be using
> sizeof()), but i don't think the current code is correct. it *should* be
> truncating 2 bytes from the comm name.
If this fixes the truncated thread names I don't care that much which fix
is being chosen. I'll leave that up to the maintainer(s) :)
BTW I don't see why we do COMM_LEN + 1 in the non-threaded name. Isn't the
process name always limited to 15 characters (plus null-termination) ?
Which is the size of COMM_LEN (=16) ? So COMM_LEN + 2 for threadname is
fine as we add 2 curly brackets, whereas you eventually have
for threads:
COMM_DISP_LEN + 1 = COMM_LEN + 2 + 1 = COMM_LEN + 3
instead of COMM_LEN + 2. What am I missing ?
--
-- dag wieers, dag at wieers.com, http://dag.wieers.com/
-- dagit linux solutions, contact at dagit.net, http://dagit.net/
[Any errors in spelling, tact or fact are transmission errors]
More information about the busybox
mailing list