Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Terminate applications opened with "subprocess.Popen()"?

I want to view an image in Eye of Gnome (eog), and then have it automatically close later. I am not very well versed in subprocess, but so far I have tried:

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

or

eog.terminate()

Neither work. Any help?

like image 369
Soviero Avatar asked Oct 10 '22 07:10

Soviero


1 Answers

Do not use shell=True, example:

import subprocess, shlex
command = 'eog <filename'>
eog = subprocess.Popen(shlex(command))
..code..
eog.kill()
like image 77
BrainStorm Avatar answered Oct 20 '22 07:10

BrainStorm