Handle partial nanosleeps in this_thread::sleep_for

Signals may result in nanosleep returning with only some of the
requested sleeping performed.

Utilize nanosleep's "time-remaining" out parameter to continue sleeping
when this occurs.

llvm-svn: 210210
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 58a0a70fb2f13a04886038744feb5d26715de8f6
diff --git a/src/thread.cpp b/src/thread.cpp
index bd2b7c3..e6f57c4 100644
--- a/src/thread.cpp
+++ b/src/thread.cpp
@@ -121,7 +121,9 @@
             ts.tv_sec = ts_sec_max;
             ts.tv_nsec = giga::num - 1;
         }
-        nanosleep(&ts, 0);
+
+        while (nanosleep(&ts, &ts) == -1 && errno == EINTR)
+            ;
     }
 }