*** keyboard.c 31 Oct 2008 08:25:09 +1100 1.977 --- keyboard.c 31 Oct 2008 08:25:19 +1100 *************** *** 7102,7118 **** { Gpm_Event event; struct input_event hold_quit; ! int gpm; EVENT_INIT (hold_quit); hold_quit.kind = NO_EVENT; while (gpm = Gpm_GetEvent (&event), gpm == 1) { nread += handle_one_term_event (tty, &event, &hold_quit); } ! if (gpm < 0) ! /* Presumably the GPM daemon has closed the connection. */ ! close_gpm (); if (hold_quit.kind != NO_EVENT) kbd_buffer_store_event (&hold_quit); if (nread) --- 7102,7123 ---- { Gpm_Event event; struct input_event hold_quit; ! int 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, so save that + for close_gpm() to remove from the select masks. + gpm==-1 if a protocol error or EWOULDBLOCK; the latter is normal. */ + fd = gpm_fd; while (gpm = Gpm_GetEvent (&event), gpm == 1) { nread += handle_one_term_event (tty, &event, &hold_quit); } ! if (gpm == 0) ! close_gpm (fd); if (hold_quit.kind != NO_EVENT) kbd_buffer_store_event (&hold_quit); if (nread)