Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List all threads

How can I list all threads within the current process in FreeBSD? Or at least, get the number of threads running.

I found the Linux system call pstat_getproc which returns a struct containing pst_nlwps, the number of threads. I am looking for something similar to this on FreeBSD.

Or perhaps there is something like /dev/fd but for threads.

Anything I can use to get some kind of idea about how many other threads are running.

I want to be able to do this programmatically in C, not using an existing application.

like image 207
user2868331 Avatar asked Oct 30 '22 20:10

user2868331


1 Answers

Use procstat(1), eg

# procstat -t $(pgrep openvpn)
  PID    TID COMM             TDNAME           CPU  PRI STATE   WCHAN    
  537 100051 openvpn          -                  0  120 sleep   select 

which depends on libprocstat(3).

like image 155
xcah Avatar answered Nov 17 '22 10:11

xcah