deplace pid file creation in child process

This commit is contained in:
Mathieu Dupuy 2014-07-24 17:49:56 +02:00 committed by deronnax
parent 6854cd0ee3
commit 4643112511

View File

@ -103,11 +103,10 @@ def run():
raise OSError("PID file exists: %s" % config.get("server", "pid")) raise OSError("PID file exists: %s" % config.get("server", "pid"))
pid = os.fork() pid = os.fork()
if pid: if pid:
try: sys.exit()
else:
if config.get("server", "pid"): if config.get("server", "pid"):
open(config.get("server", "pid"), "w").write(str(pid)) open(config.get("server", "pid"), "w").write(str(pid))
finally:
sys.exit()
sys.stdout = sys.stderr = open(os.devnull, "w") sys.stdout = sys.stderr = open(os.devnull, "w")
# Register exit function # Register exit function