if(daemonized) {
remove(PID_FILE);
}
+ if(log_fptr) {
+ fclose(log_fptr);
+ log_fptr = NULL;
+ }
}
int main(int argc, char *argv[]) {
}
check_firstrun();
if (run_as_daemon) {
+ #ifndef WIN32
/* Attempt to fork into the background if daemon mode is on. */
pid_t pid = fork();
if (pid < 0) {
fprintf(pidfile, "%i\n", (int)getpid());
fclose(pidfile);
}
- fclose(stdin);
- fclose(stdout);
- fclose(stderr);
+ fclose(stdin); fopen("/dev/null", "r");
+ fclose(stdout); fopen("/dev/null", "w");
+ fclose(stderr); fopen("/dev/null", "w");
+ #endif
}
main: