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 fails to read pipe from dict when executed in a urxvt subshell. #372
Comments
I am unable to reproduce with rxvt-unicode 9.26, dict 1.12.1/rf, bash 5.1.0(1), perl 5.32.1, on a Fedora 5.12.8 system. Running the first command produces an rxvt window with the dict output displayed. I'm wondering about the version number "less 1:633-1". The "-1" appended to the version number makes me think this came from somewhere other than a direct compile of the less-633 source. But if you've reproduced this with a direct compile of c8df315 I guess that doesn't matter. |
There is indeed an issue with reading from pipe on version 633. Version 590 on another machine is fine though. Please see this URL https://codeberg.org/nsxiv/nsxiv/issues/451 |
Can you explain how to reproduce the problem? I see a fragment of a script quoted on that page as part of a "key-handler file", but I don't know what that is nor how to invoke it. Also I don't have a program named "identify" on my system, and |
I believe identify is referring to a component of imagemagick, see https://imagemagick.org/script/identify.php |
Yes
Key bindings require |
Ok, I installed ImageMagick and copied the script into my key-handler file. Now what? Do I need to install nsxiv too? And then open a photo with ImageMagick or something? Do I need to invoke nsxiv somehow? |
Can also use
Everything is same for sxiv except key-handler need to be located at |
On the first step I get:
|
Test with |
Unfortunately I don't seem to be able to reproduce this. I tried about 25 times with 7 different jpgs, and it always opens an xterm window with less running and the identify output visible. Does it always fail when you do it? |
That's interesting.
Yes, always fails with If it consistently worked for you with |
I wonder if there is some timing issue. I notice that identify takes about 2 seconds to produce output on some jpg files (but is faster on others). Does it take a long time to produce output on the files you are using?
|
|
When |
I tried changing the config file line to
to introduce an artificial delay. In this case I see a blank xterm for 15 seconds, and then the identify output appears. So two questions:
Oh, one more thing, can you try this with less-635 or less-636? I think you're probably using less-633 which has a known issue involving startup timing. |
Yes
No, consistently no output when
Unforunately, there is still no output with either 635 or 636. 636 was missing the configure script, failed to autoconf and autoreconf as well, had to make |
@barnzen can you upload or link to one of the jpgs that you are using? It seems unlikely that the specific jpg would matter, but I want to eliminate all possible differences between our tests to try to determine why I am not reproducing what you see. |
Can't be a specific img because the problem exists for all imgs I tried, and also because The below commands consistently work at the shell prompt for
And strangely the above commands work for all
|
Ok, this is new information. I had thought that xterm was required to reproduce the problem, but you're saying that a simple pipe of identify into less is failing (as in the first command). Can you confirm whether this works?
And regarding your second to last comment, are you saying that less-635 and less-636 work when you boot from USB? Or only less-608 works in that case? |
It works.
All versions consistently work in vanilla Fedora 38 live image booted from USB, which runs Wayland instead of Xorg. |
So identify fails but cat of the same data works, but the failure goes away if you use wayland. Very strange. When it fails, do you get a prompt from less, or is it hung and needs to be killed? Could you try this, using less-636, and upload the strace.out file?
|
Sorry I gave wrong info above, this may be an The commands without
But the same command works with all versions of less on the gnome terminal:
|
Ok. Three questions:
|
Okay the problem was setting the xterm's vertical size to a value slightly larger than the screen size, the difference is less than a cell actually. With the command The same problem occurs with less verions 633 and later with both urxvt and gnome-terminal if the vertical size of the terminal is set to a value larger than the screen size. Again, only the less versions 633 and later display the problem, 608 is working well even if the the vertical size of the terminal exceeds the screen size. |
Thanks, this is very useful information to help track down where the problem is. Unfortunately I still can't reproduce it. I set my screen size (in my VM) to just barely hold a 59-line xterm, add |
Something may be masking the |
Hm, I didn't realize that the file is briefly visible. It would be interesting to see the output from running with LESS_TERMCAP_DEBUG set to 1. |
Are you using a LESSOPEN script? |
No
|
Can you apply this patch to one of the broken versions (less-633 or less-635 or less-636) and see if it fixes it for you?
|
Doesn't fix 633 or master but thanks for the effort
I'd say try to reproduce the problem for you before patching. It is reproducable for me on different machines on different terminal emulators.
All I do for xterm is change
Strangely, other commands like |
Okay, sleeping actually solves the problem lol In the first attempt, you slept before identify, and also in a subshell, so my mind must have just skipped it (I mean I tried your sleep command, but didn't think about sleeping after pipe and before less, where it would actually be needed), sorry. I thought about trying to sleep again only after realizing that
How come it fails in all terminals I tried, and only with the Still versions before 633 work in all cases, without requiring to sleep before the pipe. |
I can see in your strace output that in the failing case, less receives a SIGWINCH very early, during its first read of data from the input pipe. I guess this is X resizing the terminal from 60 to 59 lines. But somehow less is not responding appropriately to the SIGWINCH, since it doesn't redraw the screen. The patch I sent was one change that I noticed had been made to signal handling between less-608 and less-633, so I hoped that might be it, but I guess not. The sleep you added in your last test probably delays less startup enough that the SIGWINCH occurs before less starts. Perhaps I'm not able to reproduce this because my computer is faster (or slower) than yours, which is changes the timing of the SIGWINCH. I will continue to look into this. |
A couple of interesting points: I missed this before, but based on your strace it looks like less IS redrawing the screen after it receives SIGWINCH. Initially less detects the terminal as having 60 lines (line 66 in strace60.txt), then it receives SIGWINCH (line 99), then it detects that the terminal has been resized to 59 lines (line 104), then it sends what appears to be a full screen of data (in line 106 it writes 667 bytes). I don't know why this redraw data doesn't appear on the screen. Running strace on my system, less detects the initial terminal size as 59 lines, not 60, and it never receives a SIGWINCH. Perhaps I have a different version of X and it chooses the correct terminal size at startup, rather than drawing once then resizing as yours seems to do. I have |
Ok, I think I've figured this out. It should be fixed in 9d7be3c. Let me know whether that works for you. |
Nice. Thanks a lot.
For any possible future problems on this, entering help with
See the Also, Thanks again. |
The command
urxvt -e sh -c "dict -d english 'blue' | less "
produces an empty less instance with no content or an empty string. Although
urxvt -e sh -c "dict -d english 'blue' | more "
works as expected, and so does
dict -d english 'blue' | less
andurxvt -e sh -c "echo -e 'foo foo\n bar' | less"
.So just running the three programs in conjuction is the issue, running either dict or urxvt alone with less is working. With xterm 380-1 subshell, I get the following command to execute as it should
xterm -e "dict -d english 'blue' | less"
.Right now I am using:
less 1:633-1
rxvt-unicode 9.31-2 (9.26-3 appears to be the same)
rxvt-unicode-terminfo 9.31-2
dictd 1.13.1-4
linux 6.3.4-arch1-1 (Arch Linux build)
bash 5.1.16
perl 5.36.1-1 (under urxvt)
on an Acer Aspire E5-521 V1.03 laptop, AMD E2-6110 APU
This bug started occuring with v633 on the Arch Linux build, although v608 was fine. I can confirm at commit c8df315 the bug is still occuring.
The text was updated successfully, but these errors were encountered: