# HG changeset patch # User Stefan Monnier # Date 1238170463 0 # Node ID d69c45eb83b1559ae943655bb78ab80940a8c1d2 # Parent 0430833547500c216e74812969170ba691939bbd * keyboard.c (tty_read_avail_input): Don't treat a -1 return from Gpm_GetEvent as an error that justifies closing the filedescriptor. * term.c (close_gpm): Get the filedescriptor as a (new) parameter. (Fgpm_mouse_stop): Pass that new parameter. * termhooks.h (close_gpm): Adjust prototype. diff -r 043083354750 -r d69c45eb83b1 src/ChangeLog --- a/src/ChangeLog Fri Mar 27 15:58:16 2009 +0000 +++ b/src/ChangeLog Fri Mar 27 16:14:23 2009 +0000 @@ -1,3 +1,11 @@ +2009-03-27 Kevin Ryde + + * keyboard.c (tty_read_avail_input): Don't treat a -1 return from + Gpm_GetEvent as an error that justifies closing the filedescriptor. + * term.c (close_gpm): Get the filedescriptor as a (new) parameter. + (Fgpm_mouse_stop): Pass that new parameter. + * termhooks.h (close_gpm): Adjust prototype. + 2009-03-26 Stefan Monnier * lisp.h (Fx_focus_frame): Declare. diff -r 043083354750 -r d69c45eb83b1 src/keyboard.c --- a/src/keyboard.c Fri Mar 27 15:58:16 2009 +0000 +++ b/src/keyboard.c Fri Mar 27 16:14:23 2009 +0000 @@ -7184,17 +7184,23 @@ { Gpm_Event event; struct input_event hold_quit; - int gpm; + int gpm, fd = gpm_fd; EVENT_INIT (hold_quit); hold_quit.kind = NO_EVENT; + /* gpm==1 if event received. + gpm==0 if the GPM daemon has closed the connection, in which case + Gpm_GetEvent closes gpm_fd and clears it to -1, which is why + we save it in `fd' so close_gpm can remove it from the + select masks. + gpm==-1 if a protocol error or EWOULDBLOCK; the latter is normal. */ while (gpm = Gpm_GetEvent (&event), gpm == 1) { nread += handle_one_term_event (tty, &event, &hold_quit); } - if (gpm < 0) + if (gpm == 0) /* Presumably the GPM daemon has closed the connection. */ - close_gpm (); + close_gpm (fd); if (hold_quit.kind != NO_EVENT) kbd_buffer_store_event (&hold_quit); if (nread) diff -r 043083354750 -r d69c45eb83b1 src/term.c --- a/src/term.c Fri Mar 27 15:58:16 2009 +0000 +++ b/src/term.c Fri Mar 27 16:14:23 2009 +0000 @@ -3150,10 +3150,10 @@ } void -close_gpm () +close_gpm (int fd) { - if (gpm_fd >= 0) - delete_gpm_wait_descriptor (gpm_fd); + if (fd >= 0) + delete_gpm_wait_descriptor (fd); while (Gpm_Close()); /* close all the stack */ gpm_tty = NULL; } @@ -3171,7 +3171,7 @@ if (!tty || gpm_tty != tty) return Qnil; /* Not activated on this terminal, nothing to do. */ - close_gpm (); + close_gpm (gpm_fd); return Qnil; } #endif /* HAVE_GPM */ diff -r 043083354750 -r d69c45eb83b1 src/termhooks.h --- a/src/termhooks.h Fri Mar 27 15:58:16 2009 +0000 +++ b/src/termhooks.h Fri Mar 27 16:14:23 2009 +0000 @@ -653,7 +653,7 @@ extern struct terminal *initial_terminal; #ifdef HAVE_GPM -extern void close_gpm (void); +extern void close_gpm (int gpm_fd); #endif /* arch-tag: 33a00ecc-52b5-4186-a410-8801ac9f087d