proper daemonize
This commit is contained in:
parent
38f84edc01
commit
7aa6305280
13
src/bip.c
13
src/bip.c
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user