GNU bug report logs -
#19581
'sleep' return value is incorrectly rounded
Previous Next
Full log
View this message in rfc822 format
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’.
This bug report was last modified 8 years and 353 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.