* want if mkdir, chmod, chown fail...
[citadel.git] / citadel / sysdep.c
index a0ba89b2c71e3144ee2c5e59279f224bc48e7011..dfe3278f1089fff814f5262885354318747499dd 100644 (file)
@@ -745,7 +745,10 @@ void start_daemon(int unused) {
         * We don't just call close() because we don't want these fd's
         * to be reused for other files.
         */
-       chdir(ctdl_run_dir);
+       if (chdir(ctdl_run_dir) != 0)
+               CtdlLogPrintf(CTDL_EMERG, 
+                             "unable to change into directory [%s]: %s", 
+                             ctdl_run_dir, strerror(errno));
 
        child = fork();
        if (child != 0) {
@@ -758,9 +761,13 @@ void start_daemon(int unused) {
 
        setsid();
        umask(0);
-        freopen("/dev/null", "r", stdin);
-        freopen("/dev/null", "w", stdout);
-        freopen("/dev/null", "w", stderr);
+        if ((freopen("/dev/null", "r", stdin) != stdin) || 
+           (freopen("/dev/null", "w", stdout) != stdout) || 
+           (freopen("/dev/null", "w", stderr) != stderr))
+               CtdlLogPrintf(CTDL_EMERG, 
+                             "unable to reopen stdin/out/err %s", 
+                             strerror(errno));
+               
 
        do {
                current_child = fork();