1

I want to write a Python script which will start a GUI program (as in, run a binary program with subprocess.run or os.system or something). The script should not block until the program is done, it should start it and then keep running.

I'm doing this on Ubuntu.

I tried subprocess.Popen, but if I run, say subprocess.Popen("gedit"), I get strange behavior. If I open the Ubuntu system monitor (process manager), I can see that the gedit process appears when I run the script, and the gedit window itself opens. But if I close the window, the process doesn't end in the system monitor. The process stays there until my python script exits.

How can I get the behavior I want? The only thing I can think of right now is to just call subprocess.run in a different Python thread, is that the only thing I can do?

Jack M
  • 4,769
  • 6
  • 43
  • 67

2 Answers2

0

Try using subprocess.call. This has worked for me before.

subprocess.call(['command', 'arguments'])

The program should end when the window is closed.

Calvin K
  • 104
  • 2
  • 9
-1

You have to kill the subprocess you've created before you exit the program.

Try this.

rafasan
  • 176
  • 8