Ubaldo Quintero
Ubaldo Quintero

Reputation: 189

Changing system time causes application to hang LINUX (LUBUNTU) TCL/TK

I have a tcl/tk with c desktop application, and one of the requirements is to change the system time, in the background there are threads running from the c code, and "after" commands from the tcl code. Whenever I change the time to an earlier time the system hangs i.e: 05:50:12 -> 05:45:12 also i get weird behavior when going forward in time. I'm running lubuntu. I'm not sure what to do in this situation, I made some test and it seems the after keeps on waiting after i change back in time.

to change the time i use : exec date --set="STRING" from the tcl code

Upvotes: 0

Views: 244

Answers (1)

Donal Fellows
Donal Fellows

Reputation: 137627

Tcl depends on the system time (converted to seconds from the start of the Unix epoch) increasing fairly close to monotonically for the correct behaviour of a number of things, but most particularly anything in the after command. Internally, after computes the absolute time that an event should happen and only triggers things once that time is reached, so that things being triggered early (which can happen because of various OS events) don't cause problems. If you set the system time back a long way, Tcl will wait until the absolute time is reached anyway, which will look a lot like a hang.

Just synch your clock with NTP (i.e., switch on ntpd) and stop fiddling with the system clock by hand.

Upvotes: 1

Related Questions