IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40784


Ignore:
Timestamp:
Jun 6, 2019, 5:22:14 PM (7 years ago)
Author:
eugene
Message:

harvest closed kapa windows

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ohana.20190329/src/opihi/lib.data/open_kapa.c

    r31635 r40784  
    266266int close_kapa (char *name) {
    267267
     268  struct timespec request, remain;
    268269  int N;
    269270
     
    274275  }
    275276  DelKapaDevice (name);
     277
     278  // avoid blocking on waitpid, test every 1 msec, up to 500 msec
     279  request.tv_sec = 0;
     280  request.tv_nsec = 1000000;
     281
     282  // try to harvest the child PID
     283  int waitstatus = 0;
     284  int result = waitpid (-1, &waitstatus, WNOHANG);
     285  for (int i = 0; (i < 500) && (result == 0); i++) {
     286    nanosleep (&request, &remain);
     287    result = waitpid (-1, &waitstatus, WNOHANG);
     288  }
     289
     290  if ((result == -1) && (errno != ECHILD)) {
     291    fprintf (stderr, "unexpected error from waitpid (%d): programming error\n", errno);
     292  }
     293  if (result == 0) {
     294    fprintf (stderr, "child did not exit (close_kapa), timeout");
     295  }
     296
    276297  return (TRUE);
    277298}
Note: See TracChangeset for help on using the changeset viewer.