summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/sv.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/sv.c b/src/sv.c
index 6ff9bc0..bccdf71 100644
--- a/src/sv.c
+++ b/src/sv.c
@@ -1,5 +1,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <time.h>
 #include <unistd.h>
 #include "str.h"
 #include "strerr.h"
@@ -268,6 +269,17 @@ int control(char *a) {
   return(1);
 }
 
+void sleep_microseconds(unsigned int microseconds) {
+#if _POSIX_C_SOURCE >= 199309L
+  struct timespec sleeptime;
+  sleeptime.tv_sec = microseconds / 1000000;
+  sleeptime.tv_nsec = (microseconds % 1000000) * 1000L;
+  nanosleep(&sleeptime, NULL);
+#else
+  usleep(microseconds);
+#endif
+}
+
 int main(int argc, char **argv) {
   unsigned int i, done;
   char *x;
@@ -387,7 +399,7 @@ int main(int argc, char **argv) {
           fatal("unable to change to original directory");
       }
       if (done) break;
-      usleep(420000);
+      sleep_microseconds(420000);
       taia_now(&tnow);
     }
   return(rc > 99 ? 99 : rc);