emacs-devel
[Top][All Lists]
Advanced

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

FIONREAD with select


From: Nick Roberts
Subject: FIONREAD with select
Date: Sun, 6 May 2007 19:37:37 +1200

I'm trying to get Gpm (a mouse server for a console) to work with Emacs through
a Unix socket.  To do this I am using select in read_avail_input to catch mouse
events (on gpm_fd) and usual keyboard input (input_fd).  For some reason with
keyboard input, after passing through select,

ioctl (input_fd, FIONREAD, &n_to_read)

always reports no bytes to read (without select it's always 1).

Does anybody know what I'm doing wrong?

-- 
Nick                                           http://www.inet.net.nz/~nickrob


        if (n_to_read == 0)
        return 0;
  #else /* not MSDOS */
+ #ifdef HAVE_GPM
+       fd_set readset;
+       if (term_gpm)
+       {
+         Gpm_Event event;
+         int gpm = 1;
+         struct input_event hold_quit;
+         struct timeval timeout;
+ 
+         /* How long `select' should wait.  */
+         timeout.tv_sec = 0;
+         timeout.tv_usec = 10000;
+ 
+         hold_quit.kind = NO_EVENT;
+ 
+         while (gpm) {
+           FD_ZERO (&readset);
+           FD_SET (gpm_fd, &readset);
+           FD_SET (input_fd, &readset);
+ 
+           if (select (max (input_fd, gpm_fd) + 1, &readset, NULL, NULL, NULL)
+               < 0 && errno == EINTR)
+             continue;
+           gpm = FD_ISSET (gpm_fd, &readset);
+           if (gpm) {
+             if (Gpm_GetEvent (&event) > 0) {
+               nread += handle_one_term_event (&event, &hold_quit);
+             }
+             else
+               hold_quit.kind = NO_EVENT;
+           }
+         }
+         if (hold_quit.kind != NO_EVENT)
+           kbd_buffer_store_event (&hold_quit);
+       }
+ #endif /* HAVE_GPM */
  #ifdef FIONREAD
 
      /* Find out how much input is available.  */
        if (ioctl (input_fd, FIONREAD, &n_to_read) < 0)
        /* Formerly simply reported no input, but that sometimes led to
           a failure of Emacs to terminate.




reply via email to

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