* FIONREAD with select
@ 2007-05-06 7:37 Nick Roberts
2007-05-06 20:56 ` Nick Roberts
0 siblings, 1 reply; 2+ messages in thread
From: Nick Roberts @ 2007-05-06 7:37 UTC (permalink / raw)
To: emacs-devel
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: FIONREAD with select
2007-05-06 7:37 FIONREAD with select Nick Roberts
@ 2007-05-06 20:56 ` Nick Roberts
0 siblings, 0 replies; 2+ messages in thread
From: Nick Roberts @ 2007-05-06 20:56 UTC (permalink / raw)
To: emacs-devel
> I'm trying to get Gpm (a mouse server for a console) to work with Emacs
> through a Unix socket.
FIONREAD works fine, the problem is elsewhere. Sorry for the noise.
--
Nick http://www.inet.net.nz/~nickrob
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-05-06 20:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-06 7:37 FIONREAD with select Nick Roberts
2007-05-06 20:56 ` Nick Roberts
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).