Reputation:
On Linux ps -eLf | grep my-process-name
gives a list of the threads within my process along with the TID of each thread.
On OSX ps -M pid
gives me the list of the threads but does not show the TID of each thread.
How can I see thread TIDs under a single process from the command line?
Upvotes: 18
Views: 30455
Reputation: 2233
Well, although I realize it may be considered sacrilegious to some, cross platform Powershell is now available for macOS, and it's pretty trivial to see thread ids with it. This will work:
Get-Process -Id 1234 | Select-Object Threads
It will spit back an object for each applicable thread that contains about 10 properties. One of them is 'Id'. You could also do:
gps -Id 1234 | select -Expand Threads | select -Expand Id
If you wanted to shorten the command up, and just get back the Ids.
Upvotes: 4
Reputation: 1072
You can't see the TIDs with the ps
on Mac OS as you can experience while listing all the possible column options with ps L
.
Anyway, if you dont mind exploring the threads as a root, you can use dtruss
, which is primarily for processing syscall details, but it will at least show you the TIDs in the PID/LWPID (PID/THRD) column.
sudo dtruss -ap pid
Upvotes: 10