Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Is it possible to get the thread owner of a created a process ?

Let's assume that Thread1 with the process ID 40 created Process2 (Process ID 80), then Process2 want to get Thread1's ID.

Is it possible from now ?
Posted
Updated 18-May-12 2:49am
v3
Comments
Sergey Alexandrovich Kryukov 18-May-12 11:16am    
I wonder why?
--SA

1 solution

I'm almost sure this is impossible, but maybe not 100% sure. The parent-child relationships between threads are not recorded anywhere in the system, so information on the thread started a new process should not be available.
Please see this discussion:
http://stackoverflow.com/questions/5142791/how-do-i-get-to-the-parent-thread-from-a-child-thread-or-another-thread[^].
(Yes, I can see the discussed problem is different, I only suggest you consider different facts and infer the conclusion.)

At the same time, and ID of a parent process can be found (it this process still exists):
Get Parent Process PID[^].

If you really need it (please explain why), you can possibly work around the problem by passing the information of the thread to a child process using any suitable mechanism (even a command line). If you do this, be careful with a thread ID; remember that a thread could be terminated, be in one or another state at the moment you might use this ID. Actually, the whole idea of using this ID in an external process is quite concerned. I doubt that you can do anything useful with it. Again, I would be interested to know what's your idea.

—SA
 
Share this answer
 
Comments
VJ Reddy 21-May-12 13:04pm    
Good answer 5!.
Sergey Alexandrovich Kryukov 21-May-12 14:08pm    
Thank you, VJ.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900