diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2015-11-11 17:08:51 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2015-11-11 17:08:51 +0000 |
commit | f55e699d3dac1e2764920fa32bee16bfe5313ff2 (patch) | |
tree | 8a635d744d2c9f5e16d9c2d156fd9421a58463f8 /libstdc++-v3/src | |
parent | f83e226207d9458396a3a5cf9a1eb2a0092497bb (diff) | |
download | gcc-f55e699d3dac1e2764920fa32bee16bfe5313ff2.zip gcc-f55e699d3dac1e2764920fa32bee16bfe5313ff2.tar.gz gcc-f55e699d3dac1e2764920fa32bee16bfe5313ff2.tar.bz2 |
Loop in std::this_thread sleep functions
PR libstdc++/60421
* include/std/thread (this_thread::sleep_for): Retry on EINTR.
(this_thread::sleep_until): Retry if time not reached.
* src/c++11/thread.cc (__sleep_for): Retry on EINTR.
* testsuite/30_threads/this_thread/60421.cc: Test interruption and
non-steady clocks.
From-SVN: r230183
Diffstat (limited to 'libstdc++-v3/src')
-rw-r--r-- | libstdc++-v3/src/c++11/thread.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libstdc++-v3/src/c++11/thread.cc b/libstdc++-v3/src/c++11/thread.cc index e116afa..3407e80 100644 --- a/libstdc++-v3/src/c++11/thread.cc +++ b/libstdc++-v3/src/c++11/thread.cc @@ -221,7 +221,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static_cast<std::time_t>(__s.count()), static_cast<long>(__ns.count()) }; - ::nanosleep(&__ts, 0); + while (::nanosleep(&__ts, &__ts) == -1 && errno == EINTR) + { } #elif defined(_GLIBCXX_HAVE_SLEEP) # ifdef _GLIBCXX_HAVE_USLEEP ::sleep(__s.count()); |