I just noticed that ‘sleep’ essentially always rounds down its return
value, which makes it unreliable, as in this example:

--8<---------------cut here---------------start------------->8---
$ time guile -c '(sigaction SIGINT +) (call-with-new-thread (lambda () (let 
loop () (kill (getpid) SIGINT) (loop)))) (let loop ((n 3)) (when (> n 0) (loop 
(sleep (pk "s" n)))))'

;;; ("s" 3)

;;; ("s" 2)

;;; ("s" 1)

real    0m0.039s
user    0m0.052s
sys     0m0.017s
--8<---------------cut here---------------end--------------->8---

Here ‘loop’ is meant to assure we sleep for roughly 3 seconds, but
because of the incorrect rounding, we end up not sleeping at all.

Ludo’.



Reply via email to