Bug #8158
closedWant named threads API
100%
Description
Linux/BSDs and Solaris 11.3 provide pthread_setname_np() /pthread_getname_np() .
Some applications, for example, firefox, rely on this functionality.
http://man7.org/linux/man-pages/man3/pthread_setname_np.3.html
https://blogs.oracle.com/observatory/entry/named_threads .
Related issues
Updated by Jason King over 6 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 John Levon about 5 years ago
- Assignee changed from Jason King to John Levon
Updated by Electric Monk almost 5 years ago
- Status changed from New to Closed
- % Done changed from 0 to 100
git commit ab618543cc6fc4bc273c077ef5d247961cdb29d4
commit ab618543cc6fc4bc273c077ef5d247961cdb29d4 Author: John Levon <john.levon@joyent.com> Date: 2018-10-19T20:40:54.000Z 8158 Want named threads API 9857 proc manpages should have LIBRARY section Reviewed by: Andy Fiddaman <andy@omniosce.org> Reviewed by: Gordon Ross <gwr@nexenta.com> Approved by: Dan McDonald <danmcd@joyent.com>
Updated by Joshua M. Clulow almost 3 years ago
- Related to Bug #13312: _thrp_create() should not set the thread name if passed an empty string added