changeset 27432:b904070c3d8b

(sys_select): Turn atimers off and on instead of recording and restoring old alarm handler
author Gerd Moellmann <gerd@gnu.org>
date Tue, 25 Jan 2000 15:58:45 +0000
parents 92e0ea1917dd
children 87dcc6a2c31b
files src/sysdep.c
diffstat 1 files changed, 9 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/sysdep.c	Tue Jan 25 15:57:26 2000 +0000
+++ b/src/sysdep.c	Tue Jan 25 15:58:45 2000 +0000
@@ -2475,7 +2475,7 @@
      SELECT_TYPE *rfds, *wfds, *efds;
      EMACS_TIME *timeout;
 {
-  int ravail = 0, old_alarm;
+  int ravail = 0;
   SELECT_TYPE orfds;
   int timeoutval;
   int *local_timeout;
@@ -2485,7 +2485,6 @@
 #else
   extern int process_tick, update_tick;
 #endif
-  SIGTYPE (*old_trap) ();
   unsigned char buf;
 
 #if defined (HAVE_SELECT) && defined (HAVE_X_WINDOWS)
@@ -2568,10 +2567,12 @@
 	}
       if (*local_timeout == 0 || ravail != 0 || process_tick != update_tick)
 	break;
-      old_alarm = alarm (0);
-      old_trap = signal (SIGALRM, select_alarm);
+
+      turn_on_atimers (0);
+      signal (SIGALRM, select_alarm);
       select_alarmed = 0;
       alarm (SELECT_PAUSE);
+      
       /* Wait for a SIGALRM (or maybe a SIGTINT) */
       while (select_alarmed == 0 && *local_timeout != 0
 	     && process_tick == update_tick)
@@ -2589,18 +2590,10 @@
 	    pause ();
 	}
       (*local_timeout) -= SELECT_PAUSE;
-      /* Reset the old alarm if there was one */
-      alarm (0);
-      signal (SIGALRM, old_trap);
-      if (old_alarm != 0)
-	{
-	  /* Reset or forge an interrupt for the original handler. */
-	  old_alarm -= SELECT_PAUSE;
-	  if (old_alarm <= 0)
-	    kill (getpid (), SIGALRM); /* Fake an alarm with the orig' handler */
-	  else
-	    alarm (old_alarm);
-	}
+      
+      /* Reset the old alarm if there was one.  */
+      turn_on_atimers (1);
+      
       if (*local_timeout == 0)  /* Stop on timer being cleared */
 	break;
     }