I have a Python 3.9 script that starts another process in a new console. The 'other process' keeps running even after the original one has completed.
This is what I have on Windows:
# startup.py script
# =================
import sys, subprocess
if __name__ == '__main__':
print('start startup.py script')
arguments = ['python', 'other_process.py']
arguments.extend(sys.argv[1:])
subprocess.Popen(
arguments,
creationflags = subprocess.CREATE_NEW_CONSOLE,
)
print('end startup.py script')
It works great. Below you see the original console on the left, in which I invoke startup.py
. I also pass it a --help
flag, which is then simply passed to the other_process.py
script.
On the right, you see the other_process.py
script running. Please note that the original startup.py
script has already finished, while the other_process.py
script is still running. That's exactly what I need:
The subprocess.CREATE_NEW_CONSOLE
parameter doesn't work on Linux. I've heard that setting shell=True
would have a similar effect, but it doesn't spawn a new console.
How can I get the same effect on Linux?