pythonsubprocesslauncherdetachplatform-independent

Python spawn detatched non-python process on linux?


I was to make a launcher application, I haven't found a way to detach a sub-process entirely from the spawning python process.

When I launch a program with my desktop's (cinnamon's) launcher the process tree goes:

/sbin/init -> mdm -> mdm -> cinnamon-session -> cinnamon -> the-app-i-launched

Of the threads I read, this one was the most insightful/helpful: Launch a completely independent process. But gets muddied answers as the OP is looking to run python code, which can often be achieved in many usually-preferred ways than by spawning an independent process.

From other posts from stack overflow that do not answer how to launch a detatched python process:


Solution

  • A working solution can be found in JonMc's answer here. I use it to open documents using 'xdg-open'.

    You can change the stderr argument to stderr=open('/dev/null', 'w'), if you do not want a logfile.