I want my python job to start another process and exit, while keeping the child running.
When I start a subprocess using
Popen([sys.executable,"foo","bar"])
(as recommended instead of spawn), the child dies when the parent exits (the above Popen is about the last thing the parent does).
This, of course, can be remedied using nohup:
with open("/dev/null","w") as fd:
Popen(["nohup",sys.executable,"foo","bar"],stdout=fd)
(I have to redirect output to /dev/null to prevent nohup from
creating file nohup.out and announcing that misdeed on stdout).
Is there a more elegant/pythonic way to deal with this?
I also tried os.fork + signal.signal(signal.SIGHUP,signal.SIG_IGN) and the child still died when the parent exited.