[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: $SECONDS and timeout values use realtime `gettimeofday()`
From: |
Andreas Schwab |
Subject: |
Re: $SECONDS and timeout values use realtime `gettimeofday()` |
Date: |
Wed, 29 Mar 2023 17:18:51 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) |
On Mär 23 2023, William Kennington via Bug reports for the GNU Bourne Again
SHell wrote:
> We have systems that start off with inaccurate clocks and at some point
> after the boot process synchronize with the network and jump forward in
> time. This has the potential to break any scripts that are sitting in
> loops, calculating a timeout based on the $SECONDS variable. The current
> behavior using realtime instead of monotime is surprising to us.
>
> It would be nice if $SECONDS was using `clock_gettime(CLOCK_MONOTONIC,
> &val)` as it would usually make the most sense when you want to know the
> time since the script started.
Even CLOCK_MONOTONIC can jump forward. The only requirement is that it
doesn't jump backward.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."