I have a parent process which creates a thread for each client like this:
pthread_create(&thread, NULL, interact, bundle);
Then I rename each tread with:
pthread_setname_np(thread, "some name");
Running command "ps uH p " in my linux terminal, I will get thread details currently running in the parent process, but it doesn't provide the names I just assigned to them.
Is there any specific command to run and get thread names?
As hinted at in the pthread_setname_np
, the new name is accessible as ps
format specifier comm
, but not args
or command
(which is what is usually printed):
ps H -C <cmd name> -o 'pid tid args comm'
illustrates the difference (adapted from the man
page). I haven't been able to find a good piece of documentation that discusses this explicitly, though.
Here, <cmd name>
is the name of your program's binary.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.