From: Nick Roberts <nickrob@snap.net.nz>
To: emacs-devel@gnu.org
Subject: FIONREAD with select
Date: Sun, 6 May 2007 19:37:37 +1200 [thread overview]
Message-ID: <17981.34241.190694.931030@kahikatea.snap.net.nz> (raw)
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.
next reply other threads:[~2007-05-06 7:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-06 7:37 Nick Roberts [this message]
2007-05-06 20:56 ` FIONREAD with select Nick Roberts
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=17981.34241.190694.931030@kahikatea.snap.net.nz \
--to=nickrob@snap.net.nz \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).