简体   繁体   English

python的子进程启动的进程不存在

[英]process started by python's subprocess doesn't exist

I run a 'mstsc' program in win7 using python's subprocess: 我使用python的子进程在win7中运行了“ mstsc”程序:

>>> import subprocess
>>> p=subprocess.Popen('mstsc')
>>> p.pid
8884  

However, the '8884' process doesn't exist when I check Windows' process moniter, and another 'mstsc' does exist. 但是,当我检查Windows的进程监视器时,“ 8884”进程不存在,并且确实存在另一个“ mstsc”。 So I wonder if the 'mstsc' create another subprocess when calling subprocess. 所以我想知道'mstsc'在调用子流程时是否创建另一个子流程。 Please help? 请帮忙?

Well im still a newbie on python, but still you can go through this. 好吧,我仍然是python的新手,但是您仍然可以通过它。

The Popen class uses CreateProcess function in windows to execute the child program. Popen类在Windows中使用CreateProcess函数执行子程序。 CreateProcess function Creates a new process and its primary thread. CreateProcess函数创建一个新进程及其主线程。 This new process runs in the security context of the calling process. 这个新过程在调用过程的安全上下文中运行。

Internally it use the CreateProcessAsUser or CreateProcessWithLogonW functions to run the new process in the security context of the user. 在内部,它使用CreateProcessAsUser或CreateProcessWithLogonW函数在用户的安全上下文中运行新进程。

Which as per my understanding would give a different pid to actual executing suprocess.Popen(). 根据我的理解,这将为实际执行suprocess.Popen()提供不同的pid。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM