获取创建进程的线程所有者 [英] Getting the thread owner that created a process

查看:108
本文介绍了获取创建进程的线程所有者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以获取已创建进程的线程所有者?

假设进程ID为40的线程1创建了进程2(进程ID为80),则进程2要获取线程1的ID.

从现在开始有可能吗?

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 ?

推荐答案

我几乎确定这是不可能的,但也许不是100%肯定.线程之间的父子关系不会记录在系统中的任何位置,因此有关线程启动新进程的信息应该不可用.
请参阅以下讨论:
http: //stackoverflow.com/questions/5142791/how-do-i-get-to-the-parent-thread-from-a-child-thread-or-another-thread [获取父流程PID [
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


这篇关于获取创建进程的线程所有者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆