简体   繁体   English

Popen不等待Sandboxie完成

[英]Popen does not wait for Sandboxie to finish

i have an interesting problem with using Python's subprocess.Popen to run some executable (" a.exe ") to generate an image file, wait() for it with shell=False , and then i will check the filesize of this image file using os.path.getsize . 我有使用Python的一个有趣的问题subprocess.Popen运行一些可执行文件(“ a.exe ”)来生成图像文件, wait()它与shell=False ,然后我会利用检查此图像文件的文件大小os.path.getsize

when i use Popen to directly call a.exe , the file gets generated, and i can successfully retrieve the size of the image file. 当我使用a.exe直接调用a.exe ,将生成文件,并且我可以成功检索图像文件的大小。

however, as i am concerned about the security of this generation, now i use Popen with Sandboxie , which in turns run a.exe within a sandbox. 但是,由于我担心这一代的安全性,现在我将Popen与Sandboxie一起使用,后者又在沙箱中运行a.exe The problem i have is that when i try to use getsize() , the file is said to not exist. 我的问题是,当我尝试使用getsize() ,该文件据说不存在。 However, the image file is generated, perhaps just not at the point of time getsize() is called. 但是,会生成图像文件,可能只是在调用getsize()生成图像文件。

does Popen always wait() for the Sandboxie to complete? Popen是否总是wait()沙盒完成? from the docs, it seems so but in practise it is not the case. 从文档来看,似乎是这样,但实际上并非如此。 How can i make sure my code waits for Sandboxie to complete before proceeding? 我如何确保我的代码在继续之前等待沙盒完成?

http://www.sandboxie.com/?StartCommandLine http://www.sandboxie.com/?StartCommandLine

You want /wait 您想要/wait

The parameter /wait can be used to run a program, wait for it to finish, and return the exit status from the program: 参数/ wait可用于运行程序,等待其完成并返回程序的退出状态:

 "C:\\Program Files\\Sandboxie\\Start.exe" /wait cmd.exe 

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

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