]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve 'alarm' implementation on MS-Windows.
authorEli Zaretskii <eliz@gnu.org>
Mon, 1 Oct 2012 09:46:01 +0000 (11:46 +0200)
committerEli Zaretskii <eliz@gnu.org>
Mon, 1 Oct 2012 09:46:01 +0000 (11:46 +0200)
 src/w32proc.c (alarm) [HAVE_SETITIMER]: Be more conformant to the expected
 return results.
 [!HAVE_SETITIMER]: Behave as the previous version that didn't
 support timers.

src/ChangeLog
src/w32proc.c

index cfa80ed8899abe5b1dcdb101b2d739fe0ccf8b7b..d972f75454932e1c81d35ab0992ba418255b2594 100644 (file)
@@ -7,6 +7,10 @@
        (getitimer, setitimer): If disable_itimers is non-zero, return an
        error indication without doing anything.  Reported by Fabrice
        Popineau <fabrice.popineau@supelec.fr> as part of bug#12544.
+       (alarm) [HAVE_SETITIMER]: Be more conformant to the expected
+       return results.
+       [!HAVE_SETITIMER]: Behave as the previous version that didn't
+       support timers.
 
        * emacs.c (shut_down_emacs) [WINDOWSNT]: Move the call to
        term_ntproc after all the other bookkeeping, to get timers working
index 159d6e00957fe41d29fb06de7dadeb3d2109d492..b0881c25d6c5ec4d5b0c4c75c1029faaa4d6f6f5 100644 (file)
@@ -669,15 +669,19 @@ setitimer(int which, struct itimerval *value, struct itimerval *ovalue)
 int
 alarm (int seconds)
 {
-  struct itimerval new_values;
+#ifdef HAVE_SETITIMER
+  struct itimerval new_values, old_values;
 
   new_values.it_value.tv_sec = seconds;
   new_values.it_value.tv_usec = 0;
   new_values.it_interval.tv_sec = new_values.it_interval.tv_usec = 0;
 
-  setitimer (ITIMER_REAL, &new_values, NULL);
-
+  if (setitimer (ITIMER_REAL, &new_values, &old_values) < 0)
+    return 0;
+  return old_values.it_value.tv_sec;
+#else
   return seconds;
+#endif
 }
 
 /* Defined in <process.h> which conflicts with the local copy */