X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/0f8f98c8ff7e81e2853d8e6cd78d00275198c95d..c48b22c8583f6d6c55c6a6f6001cf4fdcc20aed1:/util.c diff --git a/util.c b/util.c index 4fef0b3e..bd0af33f 100644 --- a/util.c +++ b/util.c @@ -930,16 +930,28 @@ char *timestring(time_t t) } -/**************************************************************************** - like waitpid but does the WEXITSTATUS -****************************************************************************/ -#ifndef WEXITSTATUS -#define WEXITSTATUS(stat) ((int)(((stat)>>8)&0xFF)) -#endif -void wait_process(pid_t pid, int *status) +/******************************************************************* +sleep for a specified number of milliseconds +********************************************************************/ +void msleep(int t) { - waitpid(pid, status, 0); - *status = WEXITSTATUS(*status); + int tdiff=0; + struct timeval tval,t1,t2; + + gettimeofday(&t1, NULL); + gettimeofday(&t2, NULL); + + while (tdiff < t) { + tval.tv_sec = (t-tdiff)/1000; + tval.tv_usec = 1000*((t-tdiff)%1000); + + errno = 0; + select(0,NULL,NULL, NULL, &tval); + + gettimeofday(&t2, NULL); + tdiff = (t2.tv_sec - t1.tv_sec)*1000 + + (t2.tv_usec - t1.tv_usec)/1000; + } }