#include "auxlib.h" #include #include #include #include "loglib.h" void daemonize(void) { if (fork()) _exit(0); write_log = (write_log_t *) syslog; stdin = freopen("/dev/null", "r", stdin); stdout = freopen("/dev/null", "w", stdout); stderr = freopen("/dev/null", "w", stderr); setpgrp(); } void wpidfile(const char *pidfile) { FILE *fp; if (!pidfile) return; fp = fopen(pidfile, "w"); if (fp) { fprintf(fp, "%u\n", getpid()); fclose(fp); } }