[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#19581: 'sleep' return value is incorrectly rounded
From: |
Andy Wingo |
Subject: |
bug#19581: 'sleep' return value is incorrectly rounded |
Date: |
Thu, 23 Jun 2016 11:02:45 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Hi :)
On Tue 13 Jan 2015 13:58, address@hidden (Ludovic Courtès) writes:
> I just noticed that ‘sleep’ essentially always rounds down its return
> value, which makes it unreliable, as in this example:
>
> $ 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
>
> 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.
Hummmmmmmmmm.
I don't think we can change anything in 2.0. Right?
In master, how about (1) we allow sleep to take any real number, in
seconds; (2) sleep returns an inexact real number. Then we can
deprecate usleep and "standardize" on sleeping in units of seconds.
Internally we refactor scm_std_usleep/* to take a 64-bit double for the
number of seconds to sleep and return a double for the time remaining.
WDYT?
Andy
- bug#19581: 'sleep' return value is incorrectly rounded,
Andy Wingo <=