/[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.49 by sysadm, Fri May 30 12:51:00 2025 UTC Revision 1.54 by sysadm, Wed Jun 18 04:19:44 2025 UTC
# Line 58  int main(int argc, char *argv[]) Line 58  int main(int argc, char *argv[])
58          FILE *fp;          FILE *fp;
59          int ret;          int ret;
60          int last_aid;          int last_aid;
61            struct sigaction act = {0};
62    
63          // Parse args          // Parse args
64          for (int i = 1; i < argc; i++)          for (int i = 1; i < argc; i++)
# Line 78  int main(int argc, char *argv[]) Line 79  int main(int argc, char *argv[])
79                                                  app_help();                                                  app_help();
80                                                  return 0;                                                  return 0;
81                                          case 'v':                                          case 'v':
82                                                  puts(app_version);                                                  puts(APP_INFO);
83                                                  return 0;                                                  return 0;
84                                          default:                                          default:
85                                                  arg_error();                                                  arg_error();
# Line 100  int main(int argc, char *argv[]) Line 101  int main(int argc, char *argv[])
101                                  }                                  }
102                                  if (strcmp(argv[i] + 2, "version") == 0)                                  if (strcmp(argv[i] + 2, "version") == 0)
103                                  {                                  {
104                                          puts(app_version);                                          puts(APP_INFO);
105                                          return 0;                                          return 0;
106                                  }                                  }
107                                  if (strcmp(argv[i] + 2, "display-log") == 0)                                  if (strcmp(argv[i] + 2, "display-log") == 0)
# Line 137  int main(int argc, char *argv[]) Line 138  int main(int argc, char *argv[])
138    
139          if ((!daemon) && std_log_redir)          if ((!daemon) && std_log_redir)
140          {          {
141                  log_std_redirect(STDERR_FILENO);                  log_common_redir(STDERR_FILENO);
142          }          }
143          if ((!daemon) && error_log_redir)          if ((!daemon) && error_log_redir)
144          {          {
145                  log_err_redirect(STDERR_FILENO);                  log_error_redir(STDERR_FILENO);
146          }          }
147    
148            log_common("Starting %s\n", APP_INFO);
149    
150          // Load configuration          // Load configuration
151          if (load_conf(CONF_BBSD) < 0)          if (load_conf(CONF_BBSD) < 0)
152          {          {
# Line 248  int main(int argc, char *argv[]) Line 251  int main(int argc, char *argv[])
251                  last_aid = article_block_last_aid();                  last_aid = article_block_last_aid();
252          } while (ret == LOAD_ARTICLE_COUNT_LIMIT);          } while (ret == LOAD_ARTICLE_COUNT_LIMIT);
253    
254          log_std("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());
255    
256          // Set signal handler          // Set signal handler
257          signal(SIGHUP, sig_hup_handler);          act.sa_handler = sig_hup_handler;
258          signal(SIGCHLD, sig_chld_handler);          if (sigaction(SIGHUP, &act, NULL) == -1)
259          signal(SIGTERM, sig_term_handler);          {
260                    log_error("set signal action of SIGHUP error: %d\n", errno);
261                    goto cleanup;
262            }
263            act.sa_handler = sig_chld_handler;
264            if (sigaction(SIGCHLD, &act, NULL) == -1)
265            {
266                    log_error("set signal action of SIGCHLD error: %d\n", errno);
267                    goto cleanup;
268            }
269            act.sa_handler = sig_term_handler;
270            if (sigaction(SIGTERM, &act, NULL) == -1)
271            {
272                    log_error("set signal action of SIGTERM error: %d\n", errno);
273                    goto cleanup;
274            }
275    
276          // Launch section_list_loader process          // Launch section_list_loader process
277          if (section_list_loader_launch() < 0)          if (section_list_loader_launch() < 0)
# Line 292  cleanup: Line 310  cleanup:
310                  log_error("unlink(%s) error\n", VAR_SECTION_LIST_SHM);                  log_error("unlink(%s) error\n", VAR_SECTION_LIST_SHM);
311          }          }
312    
313          log_std("Main process exit normally\n");          log_common("Main process exit normally\n");
314    
315          return 0;          return 0;
316  }  }


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

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