fprintf(stderr, "Fatal error : %s\n", buf);
}
if (parent_fd) {
- write(parent_fd, buf, strlen(buf) + 1);
+ if (write(parent_fd, buf, strlen(buf) + 1) < 0)
+ ; /* Not much we can do here */
}
#endif
} else {
/* In the child we want to leave running as the daemon */
+ /* Change current directory to / */
+ if (chdir("/") < 0) {
+ LOG(LOGS_ERR, LOGF_Logging, "Could not chdir to / : %s", strerror(errno));
+ }
+
/* Don't keep stdin/out/err from before. But don't close
the parent pipe yet. */
for (fd=0; fd<1024; fd++) {
close(fd);
}
- /* Change current directory to / */
- chdir("/");
-
LOG_SetParentFd(pipefd[1]);
}
}