Ticket #3614 (closed defect: fixed)
MC is unresponsive when running under tmux in Linux virtual terminal
Reported by: | devzero | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 4.8.23 |
Component: | mc-tty | Version: | master |
Keywords: | gpm | Cc: | |
Blocked By: | #3208 | 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:2 Changed 9 years 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:9 Changed 6 years ago by andrew_b
- Blocked By 3208 added
(In #3208) Branch: 3208_gpm_connect_attempt
changeset:02764a38931a58056cf71c02647a604c9a5faedf
Please test.
comment:10 Changed 6 years ago by andrew_b
- Status changed from new to closed
- Resolution set to fixed
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.