1
0
forked from bip/bip

proper daemonize

This commit is contained in:
nohar 2006-10-21 10:36:56 +00:00
parent 38f84edc01
commit 7aa6305280

View File

@ -162,11 +162,22 @@ static pid_t daemonize(void)
case 0: case 0:
break; break;
default: default:
exit(0); _exit(0);
} }
if (setsid() < 0) if (setsid() < 0)
fatal("setsid() failed"); fatal("setsid() failed");
switch (fork()) {
case -1:
fatal("Fork failed");
break;
case 0:
break;
default:
_exit(0);
}
if (conf_log) { if (conf_log) {
snprintf(buf, 4095, "%s/bip.log", conf_log_root); snprintf(buf, 4095, "%s/bip.log", conf_log_root);
FILE *f = fopen(buf, "a"); FILE *f = fopen(buf, "a");