diff options
| author | Eli Zaretskii <eliz@gnu.org> | 2015-06-30 19:09:02 +0300 |
|---|---|---|
| committer | Eli Zaretskii <eliz@gnu.org> | 2015-06-30 19:09:02 +0300 |
| commit | 3bea77f65504ee7c4364c300fd1f7d699e2866ac (patch) | |
| tree | 2909bfde3fcd95c37b1b62632c8209d628e94310 /src | |
| parent | 43593cb4173964a978a983e2eca4cbf86e01592a (diff) | |
| download | emacs-3bea77f65504ee7c4364c300fd1f7d699e2866ac.tar.gz | |
Make sure sleep-for always delays for as long as it's told
* src/dispnew.c (Fsleep_for): Call wait_reading_process_output in
a loop, to ensure we always wait exactly the required amount of
time. (Bug#15990)
Diffstat (limited to 'src')
| -rw-r--r-- | src/dispnew.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/dispnew.c b/src/dispnew.c index 1fc3cfeef44..7833fe3d01c 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -5679,8 +5679,16 @@ additional wait period, in milliseconds; this is for backwards compatibility. if (duration > 0) { struct timespec t = dtotimespec (duration); - wait_reading_process_output (min (t.tv_sec, WAIT_READING_MAX), - t.tv_nsec, 0, 0, Qnil, NULL, 0); + struct timespec tend = timespec_add (current_timespec (), t); + + /* wait_reading_process_output returns as soon as it detects + output from any subprocess, so we wait in a loop until the + time expires. */ + do { + wait_reading_process_output (min (t.tv_sec, WAIT_READING_MAX), + t.tv_nsec, 0, 0, Qnil, NULL, 0); + t = timespec_sub (tend, current_timespec ()); + } while (timespec_sign (t) > 0); } return Qnil; |
