From 6f40812ac5395bb3411e5f3b5ffb30bce4d39db3 Mon Sep 17 00:00:00 2001 From: Patrick Ulbrich Date: Sun, 15 Sep 2013 17:46:28 +0200 Subject: [PATCH] subproc: return pid of started process --- Mailnag/common/subproc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Mailnag/common/subproc.py b/Mailnag/common/subproc.py index 6480bbf..8bddee0 100644 --- a/Mailnag/common/subproc.py +++ b/Mailnag/common/subproc.py @@ -45,15 +45,19 @@ def start_subprocess(args, shell = False, callback = None): with _lock: del _procs[t] p = None + pid = -1 try: p = subprocess.Popen(args, shell = shell) except: logging.exception('Caught an exception.') if p != None: + pid = p.pid t = threading.Thread(target = thread) with _lock: _procs[t] = p t.start() + + return pid def terminate_subprocesses():