Search code examples
multithreadingpthreadsqnxqnx-neutrino

Getting thread name from different process


We have different exes running for our application in qnx environment. And each exe inturn has several threads.

Now i want to get thread names of all the threads of all processes from a particular process. Ex: we have 10 processes with 10 threads each. So total no of threads is 100. I have to get all these 100 thread names from one of these processes (i.e., process no 5)

I tried using pthread_getname_np()

pthread_getname_np(status.tid, thredtable[threadTabIndex].ThreadName, 100);

But this returns me the thread name of the current process which is executing. Ex: It returns me threads of only process no 5 since this is being executed currently.

I have the process Ids and thread IDs of all the processes and threads. I now want to get the thread names for these.

Any suggestions will be really helpful.

Thanks in advance.


Solution

  • Using __getset_thread_name, solved the issue.

    extern int  __getset_thread_name(pid_t __pid, pthread_t __thr, const char *__newname,
                                      int __newname_len, char *__prevname, int __prevname_len);
    

    This method is defined in pthread.h