终止使用“subprocess.Popen()”打开的应用程序?

时间:2011-08-06 17:14:04

标签: python subprocess

我想在Eye of Gnome(eog)中查看图像,然后让它自动关闭。 我不太熟悉子进程,但到目前为止我已经尝试过了:

eog = subprocess.Popen('oeg <some file>', shell=True)
# ...Code, Code, Code...
eog.kill()

eog.terminate()

都没有工作。有什么帮助吗?

1 个答案:

答案 0 :(得分:3)

请勿使用shell=True,例如:

import subprocess, shlex
command = 'eog <filename'>
eog = subprocess.Popen(shlex(command))
..code..
eog.kill()
相关问题