[dev] Re: [st] Changing system clock backwards disables st

From: Christian Neukirchen <chneukirchen_AT_gmail.com>
Date: Sun, 27 Oct 2013 11:42:45 +0100

Eckehard Berns <ecki-suckless_AT_ecki.to> writes:

>> When setting the system clock backwards in time (in my particular case,
>> it was using ntpd -qg), st appears to stop painting for the difference.
>>
>> (Is it worth dealing with? The last one was 97 seconds, but it’s no
>> problem at all to just open another terminal.)
>
> I think I saw a patch for this on the list. If not, here's what I'm
> doing:
>
> Index: st-0.4.1_g0f6942c/st.c
> ===================================================================
> --- st-0.4.1_g0f6942c.orig/st.c
> +++ st-0.4.1_g0f6942c/st.c
> _AT_@ -3720,7 +3720,7 @@ run(void) {
> gettimeofday(&lastblink, NULL);
> dodraw = 1;
> }
> - if(TIMEDIFF(now, last) \
> + if(TIMEDIFF(now, last) < 0 || TIMEDIFF(now, last) \
> > (xev? (1000/xfps) : (1000/actionfps))) {
> dodraw = 1;
> last = now;

Wouldn't it be better to solve this properly by using POSIX
clock_gettime and CLOCK_MONOTONIC?

       CLOCK_MONOTONIC
              Clock that cannot be set and represents monotonic time
              since some unspecified starting point. This clock is not
              affected by discontinuous jumps in the system time (e.g.,
              if the system administrator manually changes the clock),

-- 
Christian Neukirchen  <chneukirchen_AT_gmail.com>  http://chneukirchen.org
Received on Sun Oct 27 2013 - 11:42:45 CET

This archive was generated by hypermail 2.3.0 : Sun Oct 27 2013 - 11:48:05 CET