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

Diff of /lbbs/src/net_server.c

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

Revision 1.90 by sysadm, Mon Nov 17 09:42:52 2025 UTC Revision 1.93 by sysadm, Wed Nov 19 04:15:51 2025 UTC
# Line 641  int net_server(const char *hostaddr, in_ Line 641  int net_server(const char *hostaddr, in_
641                  {                  {
642                          SYS_child_exit = 0;                          SYS_child_exit = 0;
643    
644                          pid = waitpid(-1, NULL, WNOHANG);                          pid = waitpid(-1, &ret, WNOHANG);
645                          if (pid > 0)                          if (pid > 0)
646                          {                          {
647                                  SYS_child_exit = 1; // Retry waitid                                  SYS_child_exit = 1; // Retry waitid
   
648                                  SYS_child_process_count--;                                  SYS_child_process_count--;
649                                  log_common("Child process (%d) exited\n", pid);  
650                                    if (WIFEXITED(ret))
651                                    {
652                                            log_common("Child process (%d) exited, status=%d\n", pid, WEXITSTATUS(ret));
653                                    }
654                                    else if (WIFSIGNALED(ret))
655                                    {
656                                            log_common("Child process (%d) is killed, status=%d\n", pid, WTERMSIG(ret));
657                                    }
658                                    else
659                                    {
660                                            log_common("Child process (%d) exited abnormally, status=%d\n", pid, ret);
661                                    }
662    
663                                  if (pid != section_list_loader_pid)                                  if (pid != section_list_loader_pid)
664                                  {                                  {
# Line 693  int net_server(const char *hostaddr, in_ Line 704  int net_server(const char *hostaddr, in_
704                                  log_common("Notify %d child process to exit\n", SYS_child_process_count);                                  log_common("Notify %d child process to exit\n", SYS_child_process_count);
705  #endif  #endif
706    
707                                  if (kill(-getpid(), SIGTERM) < 0)                                  if (kill(0, SIGTERM) < 0)
708                                  {                                  {
709                                          log_error("Send SIGTERM signal failed (%d)\n", errno);                                          log_error("Send SIGTERM signal failed (%d)\n", errno);
710                                  }                                  }
# Line 707  int net_server(const char *hostaddr, in_ Line 718  int net_server(const char *hostaddr, in_
718                                  sd_notifyf(0, "STATUS=Kill %d child process", SYS_child_process_count);                                  sd_notifyf(0, "STATUS=Kill %d child process", SYS_child_process_count);
719  #endif  #endif
720    
721                                  if (kill(-getpid(), SIGKILL) < 0)                                  if (kill(0, SIGKILL) < 0)
722                                  {                                  {
723                                          log_error("Send SIGKILL signal failed (%d)\n", errno);                                          log_error("Send SIGKILL signal failed (%d)\n", errno);
724                                  }                                  }
# Line 793  int net_server(const char *hostaddr, in_ Line 804  int net_server(const char *hostaddr, in_
804                          }                          }
805    
806                          // Notify child processes to reload configuration                          // Notify child processes to reload configuration
807                          if (kill(-getpid(), SIGUSR1) < 0)                          if (kill(0, SIGUSR1) < 0)
808                          {                          {
809                                  log_error("Send SIGUSR1 signal failed (%d)\n", errno);                                  log_error("Send SIGUSR1 signal failed (%d)\n", errno);
810                          }                          }
# Line 851  int net_server(const char *hostaddr, in_ Line 862  int net_server(const char *hostaddr, in_
862                                  while (!SYS_server_exit) // Accept all incoming connections until error                                  while (!SYS_server_exit) // Accept all incoming connections until error
863                                  {                                  {
864                                          addrlen = sizeof(sin);                                          addrlen = sizeof(sin);
865                                          socket_client = accept(socket_server[SSH_v2], (struct sockaddr *)&sin, &addrlen);                                          socket_client = accept(socket_server[SSH_v2], (struct sockaddr *)&sin, (socklen_t *)&addrlen);
866                                          if (socket_client < 0)                                          if (socket_client < 0)
867                                          {                                          {
868                                                  if (errno == EAGAIN || errno == EWOULDBLOCK)                                                  if (errno == EAGAIN || errno == EWOULDBLOCK)


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

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