Want named threads API
Linux/BSDs and Solaris 11.3 provide pthread_setname_np() /pthread_getname_np() .
Some applications, for example, firefox, rely on this functionality.
Updated by Jason King over 2 years ago
- Assignee set to Jason King
- Category set to kernel
It seems likely we'd want to present the thread names via /proc which would make it easy for existing utilities such as ps(1) or prstat(1m) to be able to see the thread names. It also seems useful to have the names included in any process core dumps for post-mortem debugging, though it'd be good to do it in a way that doesn't prevent any analysis of core files that predate this support.
How to implement setting the names (and where they are stored) is still under discussion.
Also need to investigate what way would be easiest if we want to be able to use it with dtrace.
For some datapoints,
Linux (or more precisely glibc on Linux) does this by (pseudo-code):
if tid == self prctl(PR_SET_NAME, name) else write(/proc/self/pid/tid/comm, name)
(Get follows a similar logic)
Freebsd uses a syscall to set the name.
Also worth noting, per the linux manpage, it silently discards characters longer than the max (16 characters) while fbsd will
Updated by Electric Monk about 1 year ago
- Status changed from New to Closed
- % Done changed from 0 to 100
commit ab618543cc6fc4bc273c077ef5d247961cdb29d4 Author: John Levon <email@example.com> Date: 2018-10-19T20:40:54.000Z 8158 Want named threads API 9857 proc manpages should have LIBRARY section Reviewed by: Andy Fiddaman <firstname.lastname@example.org> Reviewed by: Gordon Ross <email@example.com> Approved by: Dan McDonald <firstname.lastname@example.org>