emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 3bea77f: Make sure sleep-for always delays for as l


From: Eli Zaretskii
Subject: [Emacs-diffs] master 3bea77f: Make sure sleep-for always delays for as long as it's told
Date: Tue, 30 Jun 2015 16:10:20 +0000

branch: master
commit 3bea77f65504ee7c4364c300fd1f7d699e2866ac
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    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)
---
 src/dispnew.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/dispnew.c b/src/dispnew.c
index 1fc3cfe..7833fe3 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;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]