fixed timing problem with cleanup and io_flush() by using non-blocking
[rsync/rsync.git] / main.c
diff --git a/main.c b/main.c
index 32d47e6..4bd721c 100644 (file)
--- a/main.c
+++ b/main.c
@@ -25,6 +25,19 @@ struct stats stats;
 
 extern int verbose;
 
+
+/****************************************************************************
+wait for a process to exit, calling io_flush while waiting
+****************************************************************************/
+void wait_process(pid_t pid, int *status)
+{
+       while (waitpid(pid, status, WNOHANG) == 0) {
+               sleep(1);
+               io_flush();
+       }
+       *status = WEXITSTATUS(*status);
+}
+
 static void report(int f)
 {
        time_t t = time(NULL);