| 53 | |
| 54 | #ifndef HAVE_WAITPID |
| 55 | pid_t waitpid(pid_t pid, int *statptr, int options) |
| 56 | { |
| 57 | #ifdef HAVE_WAIT4 |
| 58 | return wait4(pid, statptr, options, NULL); |
| 59 | #else |
| 60 | /* If wait4 is also not available, try wait3 for SVR3 variants */ |
| 61 | /* Less ideal because can't actually request a specific pid */ |
| 62 | /* At least the WNOHANG option is supported */ |
| 63 | /* Code borrowed from apache fragment written by dwd@bell-labs.com */ |
| 64 | int tmp_pid, dummystat;; |
| 65 | if (kill(pid, 0) == -1) { |
| 66 | errno = ECHILD; |
| 67 | return -1; |
| 68 | } |
| 69 | if (statptr == NULL) |
| 70 | statptr = &dummystat; |
| 71 | while (((tmp_pid = wait3(statptr, options, 0)) != pid) && |
| 72 | (tmp_pid != -1) && (tmp_pid != 0) && (pid != -1)) |
| 73 | ; |
| 74 | return tmp_pid; |
| 75 | #endif |
| 76 | } |
| 77 | #endif |
| 78 | |
| 79 |
no outgoing calls