Changeset 41162 for trunk/Ohana/src/opihi/lib.data/open_kapa.c
- Timestamp:
- Nov 27, 2019, 11:09:40 AM (7 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/lib.data/open_kapa.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/lib.data/open_kapa.c
r31635 r41162 266 266 int close_kapa (char *name) { 267 267 268 struct timespec request, remain; 268 269 int N; 269 270 … … 274 275 } 275 276 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 276 297 return (TRUE); 277 298 }
Note:
See TracChangeset
for help on using the changeset viewer.
