GNU bug report logs - #19581
'sleep' return value is incorrectly rounded

Previous Next

Package: guile;

Reported by: ludo <at> gnu.org (Ludovic Courtès)

Date: Tue, 13 Jan 2015 12:59:02 UTC

Severity: normal

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: bug-guile <at> gnu.org
Subject: 'sleep' return value is incorrectly rounded
Date: Tue, 13 Jan 2015 13:58:04 +0100
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.