all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kevin Ryde <user42@zip.com.au>
To: 407@emacsbugs.donarmstrong.com
Subject: bug#407: gpm server stop making emacs abort()
Date: Fri, 31 Oct 2008 09:11:07 +1100	[thread overview]
Message-ID: <87ej1xsphg.fsf@blah.blah> (raw)
In-Reply-To: jwv4p4l9tvc.fsf-monnier+emacsbugreports@gnu.org

[-- Attachment #1: Type: text/plain, Size: 765 bytes --]

Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
> Huh!  Indeed!  The condition "gpm < 0" is encountered all the time,

Yes, EWOULDBLOCK.  gpm==0 is eof from the server.

gpm==-1 is a protocol error as well as EWOULDBLOCK, but it might be ok
to quietly ignore that.  It probably only happens if libgpm.so and the
running daemon are incompatible versions.

I get some joy from the change below.  I think the add/delete descriptor
calls might be right, but I'm not terrifically confident.

One thing I notice not done is to turn off the gpm-mouse-mode minor mode
variable when stopping like this.  Maybe that's good enough.  It won't
stop normally, so as long as emacs doesn't abort that could be enough.
(You can M-x gpm-mouse-mode twice to toggle it back on.)



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: keyboard.c.gpm.diff --]
[-- Type: text/x-diff, Size: 1430 bytes --]

*** 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)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: term.c.gpm.diff --]
[-- Type: text/x-diff, Size: 904 bytes --]

*** term.c	31 Oct 2008 08:23:59 +1100	1.229
--- term.c	31 Oct 2008 08:24:05 +1100	
***************
*** 3129,3138 ****
  }
  
  void
! close_gpm ()
  {
!   if (gpm_fd >= 0)
!     delete_gpm_wait_descriptor (gpm_fd);
    while (Gpm_Close()); /* close all the stack */
    gpm_tty = NULL;
  }
--- 3129,3139 ----
  }
  
  void
! close_gpm (fd)
!      int fd;
  {
!   if (fd >= 0)
!     delete_gpm_wait_descriptor (fd);
    while (Gpm_Close()); /* close all the stack */
    gpm_tty = NULL;
  }
***************
*** 3150,3156 ****
    if (!tty || gpm_tty != tty)
      return Qnil;       /* Not activated on this terminal, nothing to do.  */
  
!   close_gpm ();
    return Qnil;
  }
  #endif /* HAVE_GPM */
--- 3151,3157 ----
    if (!tty || gpm_tty != tty)
      return Qnil;       /* Not activated on this terminal, nothing to do.  */
  
!   close_gpm (gpm_fd);
    return Qnil;
  }
  #endif /* HAVE_GPM */

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: termhooks.h.gpm.diff --]
[-- Type: text/x-diff, Size: 468 bytes --]

*** termhooks.h	13 Sep 2008 07:34:28 +1000	1.98
--- termhooks.h	30 Oct 2008 18:54:52 +1100	
***************
*** 644,650 ****
  extern struct terminal *initial_terminal;
  
  #ifdef HAVE_GPM
! extern void close_gpm (void);
  #endif
  
  /* arch-tag: 33a00ecc-52b5-4186-a410-8801ac9f087d
--- 644,650 ----
  extern struct terminal *initial_terminal;
  
  #ifdef HAVE_GPM
! extern void close_gpm P_ ((int));
  #endif
  
  /* arch-tag: 33a00ecc-52b5-4186-a410-8801ac9f087d

[-- Attachment #5: Type: text/plain, Size: 120 bytes --]


-- 
The sigfile one-line movie review series:
"Cold Fever" -- easily the best Japanese-Icelandic road movie ever made.

  reply	other threads:[~2008-10-30 22:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <jwvocvndjs1.fsf-monnier+emacsbugreports@gnu.org>
2008-06-13 20:55 ` bug#407: gpm server stop making emacs abort() Kevin Ryde
2008-06-13 22:18   ` Stefan Monnier
     [not found]   ` <mailman.13216.1213396033.18990.bug-gnu-emacs@gnu.org>
2008-07-01 20:43     ` Sven Joachim
2008-07-03 22:00       ` Kevin Ryde
2008-09-12  4:14       ` Stefan Monnier
2008-09-12  5:54         ` Sven Joachim
2008-09-12 17:08           ` Stefan Monnier
2008-10-30 22:11             ` Kevin Ryde [this message]
2009-03-27 16:25   ` bug#407: marked as done (gpm server stop making emacs abort()) Emacs bug Tracking System
     [not found]   ` <handler.407.D407.123817070925838.notifdone@emacsbugs.donarmstrong.com>
2009-03-28  0:46     ` bug#407: closed by Stefan Monnier <monnier@iro.umontreal.ca> " Kevin Ryde

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ej1xsphg.fsf@blah.blah \
    --to=user42@zip.com.au \
    --cc=407@emacsbugs.donarmstrong.com \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.