Davita
Davita

Reputation: 9114

How to avoid process termination when parent process terminates in python

I have a python daemon that runs on linux. I'm implementing an auto updating functionality which works this way:

  1. When new version is detected, the app invokes updater script using subprocess.call.
  2. Child process (which is updater script in reality) stops the daemon
  3. Because the daemon is stopped, updater script also terminates :/

So my question is how can I launch updater script in a way that it won't depend on parent process. In other words, I don't want parent process termination to cause child process termination.

Environment: Linux mint 16

Python 3.3

Thanks

Upvotes: 0

Views: 144

Answers (1)

cchristelis
cchristelis

Reputation: 2015

You could do something along the lines of:

from subprocess import Popen

updater = ['/usr/bin/python', '{PATH TO}/updater_script.py', '&']
Popen(updater)

The updater won't be affected by the deamon closing.

Upvotes: 1

Related Questions