Time::Sleep always returns Time(0, 0) even if it was interrupted by a signal on Linux #44
Closed
1 task done
Labels
bug
Something isn't working
Original report (archived issue) by Silvio Traversaro (Bitbucket: traversaro).
Prerequisites
Description
Inspecting the source code, I noticed that the return value of the
clock_nanosleep
call in theTime::Sleep
method ( https://github.com/ignitionrobotics/ign-common/blob/9eb6b15c700cc641e755811c939e2867e6eaf431/src/Time.cc#L213 ) is compared against-1
to check if the sleep was interrupted before the desired elapsed time has passed. However, in Linux docs ( http://man7.org/linux/man-pages/man2/clock_nanosleep.2.html ) it is explicitly stated that the return value is a positive error message. In particular, the corresponding error should beEINTR
, that from a quick check on my Ubuntu 18.04 is equal to:So, even if
clock_nanosleep
returnsEINTR
the return value of the Sleep is always Time(0, 0).The same problem is afflicting the Gazebo's version of the method.
Steps to Reproduce
I did not attempt to reproduce the issue, but it should be reproducible by having a process sleeping for a long time, waking it with a signal before the wait period ended, and checking the return value of the
Sleep
method.Expected behavior:
Inspecting the rest of the code, I thought that the
Sleep
method was returning the remainder of time still need to pass before the requested time was elapsed, but according to the docs it is supposed to return the "Time actually slept", so I am not really sure about what the actual expected behavior his.Actual behavior:
See "Steps to Reproduced". I did not actually reproduced the error.
Reproduces how often:
The wrong check is done always, but when the
clock_nanosleep
is returning 0, the if is working as expected.Versions
ignition-common, branch gz11
Additional Information
The text was updated successfully, but these errors were encountered: