Getting a thread name

Sergey Kandaurov pluknet at gmail.com
Wed Mar 30 11:35:43 UTC 2016


On 30 March 2016 at 13:41, Willem Jan Withagen <wjw at digiware.nl> wrote:
> Hi,
>
> pthread_np has a call: pthread_set_name(tid, str).
>
> Now I'm looking for a way of retrieving that name. But there is no:
> pthread_get_name() in the same set.
>
> But I see top actually displaying the threadnames. So can somebody give
> me a hint where to look? Other than going thru top...
>

It's extracted either over kvm(3) or sysctl(3) interface depending on
your needs.  Search for kvm_getprocs() and KERN_PROC respectively.
You can also use libprocstat(3) that is a wrapper.

-- 
wbr,
pluknet


More information about the freebsd-hackers mailing list