On Fri, Apr 13 2018, "Todd C. Miller" <[email protected]> wrote:
> On Fri, 13 Apr 2018 11:11:04 -0500, Scott Cheloha wrote:
>
>> So that $SECONDS advances uniformly, independent of the system clock.
>
> Why are you including sys/time.h? For struct timespect you only
> need time.h which is already included.
>
> In general, you only need sys/time.h for struct timeval or for some
> of the time-related macros.
The diff uses timespecsub:
@@ -921,8 +922,13 @@ getspec(struct tbl *vp)
* has been set - don't do anything in this case
* (see initcoms[] in main.c).
*/
- if (vp->flag & ISSET)
- setint(vp, (int64_t)(time(NULL) - seconds));
+ if (vp->flag & ISSET) {
+ struct timespec difference, now;
+
+ clock_gettime(CLOCK_MONOTONIC, &now);
+ timespecsub(&now, &seconds, &difference);
+ setint(vp, (int64_t)difference.tv_sec);
+ }
vp->flag |= SPECIAL;
break;
case V_RANDOM:
--
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE