/[LeafOK_CVS]/lbbs/src/main.c
ViewVC logotype

Diff of /lbbs/src/main.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.50 by sysadm, Wed Jun 4 13:42:53 2025 UTC Revision 1.52 by sysadm, Tue Jun 17 01:24:21 2025 UTC
# Line 14  Line 14 
14   *                                                                         *   *                                                                         *
15   ***************************************************************************/   ***************************************************************************/
16    
17    #define _POSIX_C_SOURCE 200809L
18    
19  #include "bbs.h"  #include "bbs.h"
20  #include "init.h"  #include "init.h"
21  #include "common.h"  #include "common.h"
# Line 58  int main(int argc, char *argv[]) Line 60  int main(int argc, char *argv[])
60          FILE *fp;          FILE *fp;
61          int ret;          int ret;
62          int last_aid;          int last_aid;
63            struct sigaction act = {0};
64    
65          // Parse args          // Parse args
66          for (int i = 1; i < argc; i++)          for (int i = 1; i < argc; i++)
# Line 78  int main(int argc, char *argv[]) Line 81  int main(int argc, char *argv[])
81                                                  app_help();                                                  app_help();
82                                                  return 0;                                                  return 0;
83                                          case 'v':                                          case 'v':
84                                                  puts(app_version);                                                  puts(APP_NAME_VER);
85                                                  return 0;                                                  return 0;
86                                          default:                                          default:
87                                                  arg_error();                                                  arg_error();
# Line 100  int main(int argc, char *argv[]) Line 103  int main(int argc, char *argv[])
103                                  }                                  }
104                                  if (strcmp(argv[i] + 2, "version") == 0)                                  if (strcmp(argv[i] + 2, "version") == 0)
105                                  {                                  {
106                                          puts(app_version);                                          puts(APP_NAME_VER);
107                                          return 0;                                          return 0;
108                                  }                                  }
109                                  if (strcmp(argv[i] + 2, "display-log") == 0)                                  if (strcmp(argv[i] + 2, "display-log") == 0)
# Line 144  int main(int argc, char *argv[]) Line 147  int main(int argc, char *argv[])
147                  log_error_redir(STDERR_FILENO);                  log_error_redir(STDERR_FILENO);
148          }          }
149    
150            log_common("BBS Server (%s) is staring...\n", APP_NAME_VER);
151    
152          // Load configuration          // Load configuration
153          if (load_conf(CONF_BBSD) < 0)          if (load_conf(CONF_BBSD) < 0)
154          {          {
# Line 251  int main(int argc, char *argv[]) Line 256  int main(int argc, char *argv[])
256          log_common("Initially load %d articles, last_aid = %d\n", article_block_article_count(), article_block_last_aid());          log_common("Initially load %d articles, last_aid = %d\n", article_block_article_count(), article_block_last_aid());
257    
258          // Set signal handler          // Set signal handler
259          signal(SIGHUP, sig_hup_handler);          act.sa_handler = sig_hup_handler;
260          signal(SIGCHLD, sig_chld_handler);          if (sigaction(SIGHUP, &act, NULL) == -1)
261          signal(SIGTERM, sig_term_handler);          {
262                    log_error("set signal action of SIGHUP error: %d\n", errno);
263                    goto cleanup;
264            }
265            act.sa_handler = sig_chld_handler;
266            if (sigaction(SIGCHLD, &act, NULL) == -1)
267            {
268                    log_error("set signal action of SIGCHLD error: %d\n", errno);
269                    goto cleanup;
270            }
271            act.sa_handler = sig_term_handler;
272            if (sigaction(SIGTERM, &act, NULL) == -1)
273            {
274                    log_error("set signal action of SIGTERM error: %d\n", errno);
275                    goto cleanup;
276            }
277    
278          // Launch section_list_loader process          // Launch section_list_loader process
279          if (section_list_loader_launch() < 0)          if (section_list_loader_launch() < 0)


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1