Change directory only when detaching
authorMichael Spang <mspang@csclub.uwaterloo.ca>
Fri, 31 Jul 2009 08:29:07 +0000 (04:29 -0400)
committerMichael Spang <mspang@csclub.uwaterloo.ca>
Fri, 31 Jul 2009 08:29:07 +0000 (04:29 -0400)
src/dmaster.c

index e621ade..4751fb7 100644 (file)
@@ -68,9 +68,9 @@ static void setup_signals(void) {
 }
 
 static void setup_daemon(void) {
-    if (chdir("/"))
-        fatalpe("chdir('/')");
     if (detach) {
+        if (chdir("/"))
+            fatalpe("chdir('/')");
         pid_t pid = fork();
         if (pid < 0)
             fatalpe("fork");