From ecb8ad747e20a4fe7507d3b19e8641a0321e2ae9 Mon Sep 17 00:00:00 2001 From: Unrud Date: Tue, 22 Dec 2015 06:58:58 +0100 Subject: [PATCH] Decouple the daemon from its parent environment --- radicale/__main__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/radicale/__main__.py b/radicale/__main__.py index 879603b..6e47ee8 100644 --- a/radicale/__main__.py +++ b/radicale/__main__.py @@ -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