[Toybox] [PATCH] timeout: use the monotonic clock.
enh
enh at google.com
Thu Sep 23 13:18:25 PDT 2021
On a desktop or server the difference between the realtime and monotonic
clocks doesn't matter much, but we've seen cases on Android where
something's run under timeout(1) but killed before it's had a chance to
do anything because the device went into sleep shortly afterwards and by
the time it came back, the timeout had elapsed (as far as the realtime
clock is concerned) but the process had only had a tiny fraction of the
timeout where the system wasn't suspended.
This patch also adds an xparsetimespec() function; at this point the
only remaining users of xparsetime() are in lib, so maybe that should
become static, at least until we have another need for it?
A bigger question is whether timeout(1) needs to offer the user a choice
between the two different clocks? Although monotonic is usally the right
default choice on Android, and I don't have a specific counter-example
to hand, I can imagine that someone might actually mean "wall clock time"
rather than "cpu clock time" when setting a timeout...
Luckily, timer_create() lets us trivially choose between both clocks
if so.
---
lib/lib.h | 1 +
lib/xwrap.c | 4 ++++
scripts/make.sh | 2 +-
toys/other/reboot.c | 6 +++---
toys/other/timeout.c | 29 ++++++++++++-----------------
toys/posix/sleep.c | 6 +++---
6 files changed, 24 insertions(+), 24 deletions(-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20210923/4e655167/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-timeout-use-the-monotonic-clock.patch
Type: text/x-patch
Size: 5766 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20210923/4e655167/attachment.bin>
More information about the Toybox
mailing list