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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@210210 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Majnemer
2014-06-04 19:43:20 +00:00
parent 981b01d9d0
commit 0707b67ac3
2 changed files with 23 additions and 1 deletions

View File

@@ -121,7 +121,9 @@ sleep_for(const chrono::nanoseconds& ns)
ts.tv_sec = ts_sec_max;
ts.tv_nsec = giga::num - 1;
}
nanosleep(&ts, 0);
while (nanosleep(&ts, &ts) == -1 && errno == EINTR)
;
}
}