--- lbbs/src/main.c 2025/05/05 11:11:06 1.22 +++ lbbs/src/main.c 2025/05/09 12:58:27 1.28 @@ -1,16 +1,15 @@ /*************************************************************************** main.c - description ------------------- - begin : Mon Oct 11 2004 - copyright : (C) 2004 by Leaflet - email : leaflet@leafok.com + Copyright : (C) 2004-2025 by Leaflet + Email : leaflet@leafok.com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * + * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ @@ -132,37 +131,38 @@ int main(int argc, char *argv[]) if ((!daemon) && std_log_redir) { - log_std_redirect(2); + log_std_redirect(STDERR_FILENO); } if ((!daemon) && error_log_redir) { - log_err_redirect(3); + log_err_redirect(STDERR_FILENO); } // Load configuration - if (load_conf("conf/bbsd.conf") < 0) + if (load_conf(CONF_BBSD) < 0) + { exit(-2); + } // Load menus - if (load_menu(&bbs_menu, "conf/menu.conf") < 0) + if (load_menu(&bbs_menu, CONF_MENU) < 0) + { + unload_menu(&bbs_menu); exit(-3); + } // Set signal handler - signal(SIGCHLD, child_exit); - signal(SIGTERM, system_exit); - signal(SIG_RELOAD_MENU, reload_bbs_menu); + signal(SIGHUP, sig_hup_handler); + signal(SIGCHLD, sig_chld_handler); + signal(SIGTERM, sig_term_handler); // Initialize socket server net_server(BBS_address, BBS_port); - // Wait for child process exit - while (SYS_child_process_count > 0) - { - sleep(1); - } - // Cleanup unload_menu(&bbs_menu); + log_std("Main process exit normally\n"); + return 0; }