diff --git a/tools/profiler/platform-linux.cc b/tools/profiler/platform-linux.cc index c2a8fe8847e1..e2a7cdba19e0 100644 --- a/tools/profiler/platform-linux.cc +++ b/tools/profiler/platform-linux.cc @@ -588,8 +588,19 @@ void TickSample::PopulateContext(void* aContext) } } +// WARNING: Works with values up to 1 second void OS::SleepMicro(int microseconds) { - usleep(microseconds); + struct timespec ts; + ts.tv_sec = 0; + ts.tv_nsec = microseconds * 1000UL; + + while (true) { + // in the case of interrupt we keep waiting + // nanosleep puts the remaining to back into ts + if (!nanosleep(&ts, &ts) || errno != EINTR) { + return; + } + } }