fixed timing problem with cleanup and io_flush() by using non-blocking
authorAndrew Tridgell <tridge@samba.org>
Wed, 16 Aug 2000 08:34:18 +0000 (08:34 +0000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 16 Aug 2000 08:34:18 +0000 (08:34 +0000)
waitpid()

main.c
rsync.h
util.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);
diff --git a/rsync.h b/rsync.h
index 0742d43..588219f 100644 (file)
--- a/rsync.h
+++ b/rsync.h
@@ -510,4 +510,8 @@ size_t strlcpy(char *d, const char *s, size_t bufsize);
 size_t strlcat(char *d, const char *s, size_t bufsize);
 #endif
 
+#ifndef WEXITSTATUS
+#define        WEXITSTATUS(stat)       ((int)(((stat)>>8)&0xFF))
+#endif
+
 #define exit_cleanup(code) _exit_cleanup(code, __FILE__, __LINE__)
diff --git a/util.c b/util.c
index 4fef0b3..b961696 100644 (file)
--- a/util.c
+++ b/util.c
@@ -929,20 +929,6 @@ char *timestring(time_t t)
        return(TimeBuf);
 }
 
-
-/****************************************************************************
- like waitpid but does the WEXITSTATUS
-****************************************************************************/
-#ifndef WEXITSTATUS
-#define        WEXITSTATUS(stat)       ((int)(((stat)>>8)&0xFF))
-#endif
-void wait_process(pid_t pid, int *status)
-{
-       waitpid(pid, status, 0);
-       *status = WEXITSTATUS(*status);
-}
-
-
 #ifdef __INSURE__
 #include <dlfcn.h>