-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
less does not quit on q and does not react to any keys #108
Comments
Full
|
Looks like the tty driver is failing to set raw mode. At 22:27:19.536470 less opens /dev/tty and a few lines later calls TCSETSW to enable raw mode. But the behavior you describe sounds like the terminal is still in cooked mode, and is waiting for a newline before processing input characters. |
I pressed |
Also, shell understands and interprets keyboard arrows perfectly fine (e.g. command recalls with |
Less doesn't use fd 0 because if you pipe a file into less, fd 0 is not the terminal. So less uses /dev/tty if it exists, otherwise fd 2 which is usually the terminal but not always readable on all systems. What OS are you using? I think some older Linux versions had bugs in the /dev/tty implementation. I guess you could temporarily rename /dev/tty to force less to use fd 2 and see if that behaves differently. |
Indeed. But, well,
It's |
Hm, well this has not been reported previously so I suspect there's something in your environment that is causing less to malfunction. I'd like to see if the behavior is different when using fd 0 vs. using /dev/tty. So could you either rename /dev/tty as I suggested above, or just change line 69 in ttyin.c from |
I replaced it like this:
and was able to control BTW, I checked that replacing the |
Like I noted previously, |
Ok, so unfortunately this points to there being a bug in your /dev/tty driver. When stdin is connected to the terminal, fd 0 and /dev/tty should behave the same, but clearly they don't on your system. I might be tempted to just remove the /dev/tty node from your system since it doesn't work correctly, but that might break other programs that don't depend on /dev/tty supporting raw mode. |
Well, thanks, but unfortunately, that is not "my" system -- that's what I use. But for |
Less could be changed to dup stdin instead of opening /dev/tty, but why? If the purpose is just to workaround systems which have broken /dev/tty implementations, that raises the question of what less should do on such a system if stdin is NOT a terminal. A version of less which doesn't support input pipes would of course be unacceptable. It would also only work on systems which have the dup() system call; not all systems supported by less do so. I don't know what more is doing on your system; I guess you could use strace to find out, but it may be using some mechanism specific to Linux, which I try to avoid. In general, I'm reluctant to change code that has existed for over 20 years without any problems, merely to support a broken OS. |
Fall back to the same logic that existed for 20 years: open "/dev/tty"; or, if that fails, resort to using
Sure.
I did! And it was all attached to the very top of this thread.
Well, that is called being flexible. And that is why there's Again, I was just making a suggestion. Up to you to decide, obviously. I know how to rebuild |
Probably 4d4e6f4 helps with this too. |
I have a real
VT330
terminal connected via a serial line (@9600baud rate) to a Raspberry Pi running the latest OS with all updates current.Using
less
version 487, first page of the files gets rendered properly (that is, the screen cleared and filled up properly, last line shows status in reverse video), but thenless
stops reacting to any of the regular keys, likeq
,space
, or evencontrol-c
: everything gets echoed literally on screen, though, and whenless
is killed from outside, those typed characters get processed by the shell... So in case of a fewq
's typed (withEnter
in between then),bash
prints "q: command not found
"...Here goes the relevant part of
strace
, showing thatless
reads from the terminal but does not get any input characters...The command was:
less /etc/terminfo/README
Not sure why it reads from descriptor 3, though, as the terminal input is usually at 0.
more
works perfectly fine, with spacebar advancing the pages, andq
quitting the program...The text was updated successfully, but these errors were encountered: