IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 18, 2006, 1:44:51 PM (20 years ago)
Author:
eugene
Message:

successful implementation of the threaded version of pcontrol

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/pcontrol/StopHosts.c

    r8296 r8424  
    1919int DownHosts () {
    2020
    21   int i, Nobject;
    2221  Stack *stack;
    2322  Host  *host;
     
    6867int HarvestHost (int pid) {
    6968 
    70   int       result;
    71   int       waitstatus;
     69  int i, result, waitstatus;
    7270
    73   /* I probably should loop a few time with max timeout larger than 10ms... */
    74   usleep (10000);
    75   result = waitpid (pid, &waitstatus, WNOHANG);
     71  gprint (GP_ERR, "harvesting within thread %d\n", pthread_self());
     72  gprint (GP_ERR, "child process %d is down, wait for exit status\n", pid);
     73 
     74  // Loop a few times waiting for child to exit
     75  for (i = 0; i < 50; i++) {
     76    result = waitpid (pid, &waitstatus, WNOHANG);
     77    if ((result == -1) && (errno == ECHILD)) {
     78      usleep (10000);
     79      continue;
     80    } else {
     81      break;
     82    }
     83  }
    7684  switch (result) {
    7785    case -1:  /* error with waitpid */
     
    8189          gprint (GP_ERR, "did process already exit?  programming error?\n");
    8290          break;
     91        case EINTR:
    8392        case EINVAL:
    84           gprint (GP_ERR, "error EINVAL (waitpid): programming error\n");
    85           exit (1);
    86         case EINTR:
    87           gprint (GP_ERR, "error EINTR (waitpid): programming error\n");
    88           exit (1);
    8993        default:
    90           gprint (GP_ERR, "unknown error for waitpid (%d): programming error\n", errno);
    91           exit (1);
     94          perror ("unexpected error");
     95          ABORT ("(HarvestHost)");
    9296      }
    9397      break;
Note: See TracChangeset for help on using the changeset viewer.