Ticket #3614 (new defect)

Opened 21 months ago

Last modified 44 hours ago

MC is unresponsive when running under tmux in Linux virtual terminal

Reported by: devzero Owned by:
Priority: major Milestone: 4.8.21
Component: mc-tty Version: master
Keywords: gpm Cc:
Blocked By: Blocking:
Branch state: no branch Votes for changeset:

Description

MC randomly stucks reading input when the following coditions met:

  • MC is running under tmux or another terminal multiplexer.
  • tmux itself is running in Linux virtual terminal.
  • GPM is running.

MC tries to connect to GPM and then stucks reading GPM events. Under these conditions, MC is actually running in a pseudo terminal created by tmux, not in a virtual terminal, so we should not try connecting to GPM. The possible solution is to check ttyname in init_mouse(). If ttyname is /dev/tty*, it is a virtual terminal.

diff --git a/lib/tty/mouse.c b/lib/tty/mouse.c
index e9542e2..6546802 100644
--- a/lib/tty/mouse.c
+++ b/lib/tty/mouse.c
@@ -84,7 +84,15 @@ init_mouse (void)
     {
 #ifdef HAVE_LIBGPM
     case MOUSE_NONE:
-        use_mouse_p = MOUSE_GPM;
+        {
+            /* check if stdin is a linux virtual terminal */
+            char tname[64];
+            if (ttyname_r(0, tname, sizeof(tname)/sizeof(tname[0])) == 0 &&
+                strncmp(tname, "/dev/tty", sizeof("/dev/tty") - 1) == 0)
+            {
+                use_mouse_p = MOUSE_GPM;
+            }
+        }
         break;
 #endif /* HAVE_LIBGPM */
 

Change History

comment:1 Changed 20 months ago by zaytsev

  • Milestone changed from Future Releases to 4.8.17

Patch attached, so moving to 4.8.17 (can reschedule later if it doesn't work out), also need to check for other related tickets and link them if there are any, this issue is not new by any means.

comment:2 Changed 20 months ago by ossi

this code would also trigger on ttyS0, ttyUSB0, and dog knows what else.
furthermore, it will not trigger on systems which use a different naming pattern for local consoles.

a more reliable approach would be issuing an ioctl that is specific to local consoles (see console_ioctl(4), as opposed to tty_ioctl(4)).
that's still linux-specific, though, so it will be quite an ifdef mess.

i suggest taking some "inspiration" from the gpm source itself.

comment:3 Changed 20 months ago by zaytsev

Can this be a duplicate of #3208?

comment:4 Changed 19 months ago by zaytsev

  • Milestone changed from 4.8.17 to 4.8.18

comment:5 Changed 14 months ago by zaytsev

  • Milestone changed from 4.8.18 to 4.8.19

comment:6 Changed 44 hours ago by zaytsev

  • Milestone changed from 4.8.20 to 4.8.21
Note: See TracTickets for help on using tickets.