#include "auxlib.h"
|
|
#include <stdio.h>
|
|
#include <sys/types.h>
|
|
#include <unistd.h>
|
|
#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);
|
|
}
|
|
}
|