When i use python-daemon in code, subprocess cannot exec
def main_pro():
#some code
cmd="/path/to/alert.py " + ip + " "+ title + " " + content
handler = subprocess.Popen(args = cmd, shell = True, stdout = subprocess.PIPE)
#some other code
context = daemon.DaemonContext(
working_directory='/',
umask=0o002,
pidfile=lockfile.FileLock('/tmp/Mon.pid'),
)
context.signal_map = {
signal.SIGCLD:None,
signal.SIGTERM:mon_exit,
}
with context:
main_pro()
the code that above is cannot exec subprocess, because cmd
has log
when i use main_pro direct, subprocess is worked ,just like this:
def main_pro():
#some code
cmd="/path/to/alert.py " + ip + " "+ title + " " + content
handler = subprocess.Popen(args = cmd, shell = True, stdout = subprocess.PIPE)
#some other code
main_pro()