--- lbbs/src/bbs_main.c 2025/11/08 08:21:31 1.103 +++ lbbs/src/bbs_main.c 2025/11/20 09:02:46 1.111 @@ -6,6 +6,10 @@ * Copyright (C) 2004-2025 Leaflet */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "article_favor.h" #include "article_view_log.h" #include "bbs.h" @@ -26,6 +30,7 @@ #include "trie_dict.h" #include "user_list.h" #include "user_priv.h" +#include #include #include #include @@ -33,9 +38,18 @@ #include #include +static void child_proc_sig_usr1_handler(int i) +{ + // Restart log + if (log_restart() < 0) + { + log_error("Restart logging failed\n"); + } +} + int bbs_info() { - prints("欢迎光临 \033[1;33m%s \033[32m[%s] \033[37m( %s )\033[m\r\n", + prints("\r\n欢迎光临 \033[1;33m%s \033[32m[%s] \033[37m(%s)\033[m\r\n", BBS_name, BBS_server, APP_INFO); return iflush(); @@ -80,7 +94,7 @@ int bbs_welcome(void) "\033[32m目前上站人数 [\033[36m%d/%d\033[32m] " "匿名游客[\033[36m%d\033[32m] " "注册用户数[\033[36m%d/%d\033[32m]\r\n" - "从 [\033[36m%s\033[32m] 起,累计访问人次:[\033[36m%d\033[32m]\033[m\r\n", + "从 [\033[36m%s\033[32m] 起,累计访问人次: [\033[36m%d\033[32m]\033[m\r\n", BBS_name, u_online, BBS_max_client, u_anonymous, u_total, BBS_max_user_count, BBS_start_dt, u_login_count); @@ -205,11 +219,11 @@ int bbs_charset_select() int ch; snprintf(msg, sizeof(msg), - "\rChoose character set in 3 seconds [UTF-8, GBK]: [U/g]"); + "\rChoose character set in 5 seconds, (U)UTF-8, (G)GBK [U]: "); while (!SYS_server_exit) { - ch = press_any_key_ex(msg, 3); + ch = press_any_key_ex(msg, 5); switch (toupper(ch)) { case KEY_NULL: @@ -233,23 +247,23 @@ int bbs_charset_select() } snprintf(msg, sizeof(msg), - "\rChoose wide-character display in 3 seconds [Fixed, Dynamic]: [F/d]"); + "\r请在5秒内选择宽字符显示规则, (V)变宽, (F)定宽? [V]: "); while (!SYS_server_exit) { - ch = press_any_key_ex(msg, 3); + ch = press_any_key_ex(msg, 5); switch (toupper(ch)) { case KEY_NULL: return -1; case KEY_TIMEOUT: case CR: + case 'V': + UTF8_fixed_width = 0; + break; case 'F': UTF8_fixed_width = 1; break; - case 'D': - UTF8_fixed_width = 0; - break; default: continue; } @@ -278,6 +292,12 @@ int bbs_main() log_error("set signal action of SIGCHLD error: %d\n", errno); goto cleanup; } + act.sa_handler = child_proc_sig_usr1_handler; + if (sigaction(SIGUSR1, &act, NULL) == -1) + { + log_error("set signal action of SIGUSR1 error: %d\n", errno); + goto cleanup; + } // Set data pools in shared memory readonly if (set_trie_dict_shm_readonly() < 0) @@ -292,10 +312,12 @@ int bbs_main() { goto cleanup; } +#ifdef HAVE_SYSTEM_V if (set_user_list_pool_shm_readonly() < 0) { goto cleanup; } +#endif // Load menu in shared memory if (set_menu_shm_readonly(&bbs_menu) < 0) @@ -313,7 +335,10 @@ int bbs_main() set_input_echo(0); // Set user charset - bbs_charset_select(); + if (bbs_charset_select() < 0) + { + goto cleanup; + } // System info if (bbs_info() < 0)