diff src/event-unixoid.c @ 771:943eaba38521

[xemacs-hg @ 2002-03-13 08:51:24 by ben] The big ben-mule-21-5 check-in! Various files were added and deleted. See CHANGES-ben-mule. There are still some test suite failures. No crashes, though. Many of the failures have to do with problems in the test suite itself rather than in the actual code. I'll be addressing these in the next day or so -- none of the test suite failures are at all critical. Meanwhile I'll be trying to address the biggest issues -- i.e. build or run failures, which will almost certainly happen on various platforms. All comments should be sent to ben@xemacs.org -- use a Cc: if necessary when sending to mailing lists. There will be pre- and post- tags, something like pre-ben-mule-21-5-merge-in, and post-ben-mule-21-5-merge-in.
author ben
date Wed, 13 Mar 2002 08:54:06 +0000
parents fdefd0186b75
children e38acbeb1cae
line wrap: on
line diff
--- a/src/event-unixoid.c	Fri Mar 08 13:33:14 2002 +0000
+++ b/src/event-unixoid.c	Wed Mar 13 08:54:06 2002 +0000
@@ -3,7 +3,7 @@
    Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
    Copyright (C) 1995 Board of Trustees, University of Illinois.
    Copyright (C) 1995 Sun Microsystems, Inc.
-   Copyright (C) 1995, 1996 Ben Wing.
+   Copyright (C) 1995, 1996, 2001 Ben Wing.
 
 This file is part of XEmacs.
 
@@ -71,17 +71,26 @@
 int fake_event_occurred;
 
 int
-read_event_from_tty_or_stream_desc (Lisp_Event *event,
-				    struct console *con, int fd)
+read_event_from_tty_or_stream_desc (Lisp_Event *event, struct console *con)
 {
-  unsigned char ch;
-  int nread;
+  Emchar ch;
   Lisp_Object console;
 
   XSETCONSOLE (console, con);
 
-  nread = read (fd, &ch, 1);
-  if (nread <= 0)
+  if (CONSOLE_TTY_P (con))
+    ch = Lstream_get_emchar (XLSTREAM (CONSOLE_TTY_DATA (con)->instream));
+  else
+    {
+      /* #### Definitely something strange here.  We should be setting
+	 the stdio handle unbuffered and reading from it instead of mixing
+	 stdio and raw io calls. */
+      int nread = retry_read (fileno (CONSOLE_STREAM_DATA (con)->in), &ch, 1);
+      if (nread <= 0)
+	ch = -1;
+    }
+
+  if (ch < 0)
     {
       /* deleting the console might not be safe right now ... */
       enqueue_magic_eval_event (io_error_delete_console, console);
@@ -110,14 +119,14 @@
      an iteration of the command loop, e.g. in status_notify()),
      but before we set the blocking flag.
 
-     This should be OK as long as write() is reentrant, which
-     I'm fairly sure it is since it's a system call. */
+     This should be OK as long as write() is reentrant, which I'm fairly
+     sure it is since it's a system call. */
 
   if (signal_event_pipe_initialized)
     /* In case a signal comes through while we're dumping */
     {
       int old_errno = errno;
-      write (signal_event_pipe[1], &byte, 1);
+      retry_write (signal_event_pipe[1], &byte, 1);
       errno = old_errno;
     }
 }
@@ -127,7 +136,7 @@
 {
   char chars[128];
   /* The input end of the pipe has been set to non-blocking. */
-  while (read (signal_event_pipe[0], chars, sizeof (chars)) > 0)
+  while (retry_read (signal_event_pipe[0], chars, sizeof (chars)) > 0)
     ;
 }
 
@@ -264,7 +273,7 @@
       if (outfd < 0)
 	{
 	  if (infd >= 0)
-	    close (infd);
+	    retry_close (infd);
 	  return USID_ERROR;
 	}
     }
@@ -311,9 +320,9 @@
 	     : filedesc_stream_fd (XLSTREAM (outstream)));
 
   if (in >= 0)
-    close (in);
+    retry_close (in);
   if (out != in && out >= 0)
-    close (out);
+    retry_close (out);
 
   return FD_TO_USID (in);
 }