Wait for a process to exit, calling io_flush while waiting. */
| 192 | |
| 193 | /* Wait for a process to exit, calling io_flush while waiting. */ |
| 194 | static void wait_process_with_flush(pid_t pid, int *exit_code_ptr) |
| 195 | { |
| 196 | pid_t waited_pid; |
| 197 | int status; |
| 198 | |
| 199 | while ((waited_pid = wait_process(pid, &status, WNOHANG)) == 0) { |
| 200 | msleep(20); |
| 201 | io_flush(FULL_FLUSH); |
| 202 | } |
| 203 | |
| 204 | /* TODO: If the child exited on a signal, then log an |
| 205 | * appropriate error message. Perhaps we should also accept a |
| 206 | * message describing the purpose of the child. Also indicate |
| 207 | * this to the caller so that they know something went wrong. */ |
| 208 | if (waited_pid < 0) { |
| 209 | rsyserr(FERROR, errno, "waitpid"); |
| 210 | *exit_code_ptr = RERR_WAITCHILD; |
| 211 | } else if (!WIFEXITED(status)) { |
| 212 | #ifdef WCOREDUMP |
| 213 | if (WCOREDUMP(status)) |
| 214 | *exit_code_ptr = RERR_CRASHED; |
| 215 | else |
| 216 | #endif |
| 217 | if (WIFSIGNALED(status)) |
| 218 | *exit_code_ptr = RERR_TERMINATED; |
| 219 | else |
| 220 | *exit_code_ptr = RERR_WAITCHILD; |
| 221 | } else |
| 222 | *exit_code_ptr = WEXITSTATUS(status); |
| 223 | } |
| 224 | |
| 225 | void write_del_stats(int f) |
| 226 | { |
no test coverage detected