--- lbbs/src/bbs_main.c 2025/06/18 02:29:54 1.71 +++ lbbs/src/bbs_main.c 2025/06/25 01:50:14 1.75 @@ -14,30 +14,32 @@ * * ***************************************************************************/ -#include "bbs_main.h" +#include "article_view_log.h" #include "bbs.h" -#include "login.h" -#include "user_priv.h" +#include "bbs_cmd.h" +#include "bbs_main.h" #include "common.h" #include "database.h" -#include "article_view_log.h" -#include "log.h" +#include "editor.h" #include "io.h" -#include "screen.h" +#include "log.h" +#include "login.h" #include "menu.h" -#include "bbs_cmd.h" +#include "screen.h" #include "section_list.h" #include "trie_dict.h" -#include "editor.h" -#include -#include -#include +#include "user_priv.h" +#include +#include #include +#include +#include +#include int bbs_info() { prints("»¶Ó­¹âÁÙ \033[1;33m%s \033[32m[%s] \033[37m( %s )\r\n", - BBS_name, BBS_server, APP_NAME_VER); + BBS_name, BBS_server, APP_INFO); return iflush(); } @@ -204,20 +206,20 @@ int bbs_center() show_top("", BBS_name, ""); show_active_board(); show_bottom(""); - display_menu(p_bbs_menu); + display_menu(&bbs_menu); iflush(); while (!SYS_server_exit) { ch = igetch(100); - if (p_bbs_menu->choose_step == 0 && time(NULL) - t_last_action >= 10) + if (bbs_menu.choose_step == 0 && time(NULL) - t_last_action >= 10) { t_last_action = time(NULL); show_active_board(); show_bottom(""); - display_menu_cursor(p_bbs_menu, 1); + display_menu_cursor(&bbs_menu, 1); iflush(); } @@ -239,9 +241,10 @@ int bbs_center() case CR: igetch_reset(); default: - switch (menu_control(p_bbs_menu, ch)) + switch (menu_control(&bbs_menu, ch)) { case EXITBBS: + case EXITMENU: return 0; case REDRAW: t_last_action = time(NULL); @@ -249,7 +252,7 @@ int bbs_center() show_top("", BBS_name, ""); show_active_board(); show_bottom(""); - display_menu(p_bbs_menu); + display_menu(&bbs_menu); break; case NOREDRAW: case UNKNOWN_CMD: @@ -267,6 +270,22 @@ int bbs_center() int bbs_main() { + struct sigaction act = {0}; + + // Set signal handler + act.sa_handler = SIG_IGN; + if (sigaction(SIGHUP, &act, NULL) == -1) + { + log_error("set signal action of SIGHUP error: %d\n", errno); + goto cleanup; + } + act.sa_handler = SIG_DFL; + if (sigaction(SIGCHLD, &act, NULL) == -1) + { + log_error("set signal action of SIGCHLD error: %d\n", errno); + goto cleanup; + } + // Set data pools in shared memory readonly if (set_trie_dict_shm_readonly() < 0) { @@ -282,7 +301,7 @@ int bbs_main() } // Load menu in shared memory - if (set_menu_shm_readonly(p_bbs_menu) < 0) + if (set_menu_shm_readonly(&bbs_menu) < 0) { goto cleanup; } @@ -352,9 +371,7 @@ cleanup: article_view_log_unload(&BBS_article_view_log); // Detach menu in shared memory - detach_menu_shm(p_bbs_menu); - free(p_bbs_menu); - p_bbs_menu = NULL; + detach_menu_shm(&bbs_menu); // Detach data pools shm detach_section_list_shm();