--- lbbs/src/init.c 2025/04/30 09:18:19 1.13 +++ lbbs/src/init.c 2025/05/04 14:54:55 1.15 @@ -16,6 +16,7 @@ ***************************************************************************/ #include "init.h" +#include "database.h" #include "bbs.h" #include "common.h" #include "log.h" @@ -31,21 +32,34 @@ void init_daemon(void) { int pid; - int i; - if (pid = fork()) + pid = fork(); + + if (pid > 0) // Parent process + { exit(0); - else if (pid < 0) + } + else if (pid < 0) // Error + { exit(1); + } + // Child process setsid(); - if (pid = fork()) + pid = fork(); + + if (pid > 0) // Parent process + { exit(0); - else if (pid < 0) + } + else if (pid < 0) // Error + { exit(1); + } - umask(0); + // Child process + umask(022); return; }