Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, October 16, 2026

Diff for ep/src/main.c between version 1.8 and 1.9

version 1.8, 2001/12/20 00:26:52 version 1.9, 2002/02/05 22:37:03
Line 2 
Line 2 
  * ep - extended pipelining   * ep - extended pipelining
  * coding start date: 11.11.2000   * coding start date: 11.11.2000
  * authors: Ondrej Jombik   * authors: Ondrej Jombik
  *          Lubomir Host  *          Lubomir Host
  *                      Martin Karas   *                      Martin Karas
  * copyright: (c) 2000-2001 Platon software development group   * Copyright (c) 2000-2002 Platon software development group
  * license: GNU General Public License   * license: GNU General Public License
  *   *
  * $Log$   * $Id$
  * Revision 1.8  2001/12/20 00:26:52  jombik9  
  * Various Makefile & code improvements.  
  * wait() implementation - no error is reported on ctrl+d now  
  *  
  * Revision 1.7  2001/12/04 17:17:52  jombik9  
  * n_link sychronizations  
  *  
  * Revision 1.6  2001/12/02 23:30:07  jombik9  
  * A lot of new functions added.  
  * Various improvements.  
  *  
  * Revision 1.5  2001/09/21 19:58:47  host8  
  * Cosmetics changes  
  *  
  * Revision 1.4  2001/09/21 19:55:36  host8  
  * Cosmetics changes in main.c  
  *  
  * Revision 1.3  2001/09/21 19:54:45  host8  
  * Cosmetics changes in *.c  
  */   */
   
 #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
Line 96  void exit_fnc(void)
Line 77  void exit_fnc(void)
         /*          /*
            msg_print("exit_fnc(): ep shutting down, sending all process SIGTERM...\n");             msg_print("exit_fnc(): ep shutting down, sending all process SIGTERM...\n");
            kill(0, SIGTERM);             kill(0, SIGTERM);
          */             */
 #if DEBUG  #if DEBUG
         msg_debug_print("exit_fnc(): %s terminating\n", argv0);          msg_debug_print("exit_fnc(): %s terminating\n", argv0);
 #endif  #endif
Line 115  main(argc, argv)
Line 96  main(argc, argv)
 {  {
         register int i, k;          register int i, k;
         register int ret;          register int ret;
         register int ebadf_count;          /* register int ebadf_count; */
         PROCTABLE ptbl;          PROCTABLE ptbl;
         fd_set fds;          fd_set fds;
   
Line 188  main(argc, argv)
Line 169  main(argc, argv)
                 return 1;                  return 1;
         }          }
   
 #if 0  
         /* Instaling signal handler. */          /* Instaling signal handler. */
         sigserv_init(ptbl);          /* sigserv_init(ptbl); */
 #endif  
   
 #if DEBUG  #if DEBUG
         /* Proctable print. */          /* Proctable print. */
Line 200  main(argc, argv)
Line 179  main(argc, argv)
   
         /* Main loop. */          /* Main loop. */
         while (1) {          while (1) {
                   /*
                      ebadf_count = 0;
   
                      while (1) {
                      */
                   struct timeval tv;
                   int pid = 0;
   
                   do {
   
                 ebadf_count = 0;  
   
                 while (1) {                          /* Wait up to five seconds. */
                           tv.tv_sec = 1;
                           tv.tv_usec = 0;
   
                         /* Set fds. */                          /* Set fds. */
                         FD_ZERO(&fds);                          FD_ZERO(&fds);
                         FD_SET(0, &fds);  
                         for (i = 0; ptbl[i] != NULL; i++)                          for (i = 0; ptbl[i] != NULL; i++)
                                 for (k = (i ? 1 : 0); k < (i ? N_FD : 1); k++)                                  for (k = (i ? 1 : 0); k < (i ? N_FD : 1); k++)
                                         if (0 || ptbl[i]->fd[k].n_link != 0)                                          if (ptbl[i]->fd[k].n_link != 0)
                                                 FD_SET(ptbl[i]->fd[k].pipe[0], &fds);                                                  FD_SET(ptbl[i]->fd[k].pipe[0], &fds);
   
                         ret = select(FD_SETSIZE, &fds, NULL, NULL, NULL);                          /* Check if processes still running. */
                         if (ret >= 0)                          pid = proctable_wait(&ptbl);
                                 break;  
   
                         if (errno != EBADF || ebadf_count > MAX_EBADF_COUNT) {                          if (pid < 0) {
                                 msg_error_print("select() failure: %s\n", strerror(errno));                                  msg_error_print("waitpid() failure: %s\n", strerror(errno));
                                   proctable_destroy(&ptbl);
                                 return errno;                                  return errno;
                         }                          }
                         else {  
                                 register int size;  
   
                                 int status;                  } while (pid > 0);
                                 int pid;  
                                 int idx;  
   
                                 pid = waitpid(-1, &status, WNOHANG);  
   
                                 if (pid > 0) {  
                                         idx = proctable_get_process_index_by_pid(ptbl, pid);  
                                         if (proctable_remove_process(&ptbl, idx) < 0) {  
                                                 msg_error_print("error during removing process from proctable\n");  
                                                 exit(1);  
                                         }  
                                 }  
   
                                 if ((size = proctable_get_size(ptbl)) < 2)                  {
                                         return 0;                          register int size = proctable_get_size(ptbl);
 #if DEBUG  #if DEBUG
                                 msg_debug_print("proctable_get_size() = %d\n", size);                          msg_debug_print("main(): proctable_get_size() = %d\n", size);
 #endif  #endif
                                 ebadf_count++;                          if (size < 2)
                         }                                  break;
                   }
   
                   ret = select(FD_SETSIZE, &fds, NULL, NULL, /*&tv/*/NULL/**/);
                   if (ret >= 0)
                           ;
                   /* break; */
   
                   if (ret < 0 /*|| errno != EBADF || ebadf_count > MAX_EBADF_COUNT*/) {
                           msg_error_print("select() failure: %s\n", strerror(errno));
                           proctable_destroy(&ptbl);
                           return errno;
                   }
                   else {
                           /*
                              register int size;
   
                              int status;
                              int pid;
                              int idx;
   
                              pid = waitpid(-1, &status, WNOHANG);
   
                              if (pid > 0) {
                              idx = proctable_get_process_index_by_pid(ptbl, pid);
                              if (proctable_remove_process(&ptbl, idx) < 0) {
                              msg_error_print("error during removing process from proctable\n");
                              exit(1);
                              }
                              }
   
                              if ((size = proctable_get_size(ptbl)) < 2)
                              return 0;
   #if DEBUG
   msg_debug_print("proctable_get_size() = %d\n", size);
   #endif
   ebadf_count++;
   */
                 }                  }
                   /*}*/
   
 #if MENU  #if MENU
                 if (FD_ISSET(0, &fds)) {                  if (FD_ISSET(0, &fds)) {
Line 272  main(argc, argv)
Line 285  main(argc, argv)
                 /* Read and transfer data. */                  /* Read and transfer data. */
                 proctable_read(&ptbl, &fds);                  proctable_read(&ptbl, &fds);
   
                 /* Check if processes still running. */  
                 proctable_wait(&ptbl);  
   
                 /* msg_debug_print("switch(select()) = default\n"); */  
   
         }          }
   
           proctable_destroy(&ptbl);
   
         /* We will never been here. */  
         return 0;          return 0;
 }  }
   

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top