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:
break;
default:
exit(0);
_exit(0);
}
if (setsid() < 0)
fatal("setsid() failed");
switch (fork()) {
case -1:
fatal("Fork failed");
break;
case 0:
break;
default:
_exit(0);
}
if (conf_log) {
snprintf(buf, 4095, "%s/bip.log", conf_log_root);
FILE *f = fopen(buf, "a");