Decouple the daemon from its parent environment

This commit is contained in:
Unrud 2015-12-22 06:58:58 +01:00 committed by Unrud
parent 3a9238f670
commit ecb8ad747e

View File

@ -114,6 +114,10 @@ def run():
if config.get("server", "pid"):
with os.fdopen(pid_fd, "w") as pid_file:
pid_file.write(str(os.getpid()))
# Decouple environment
os.umask(0)
os.chdir("/")
os.setsid()
sys.stdout = sys.stderr = open(os.devnull, "w")
# Register exit function