You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Nushell can't handle well with less command on MacOS #6496
However, when an additional process is present in the pipeline, such as ^yes | ^head -n 999 | LESS= ^less then it does not quit on q and the process tree shows that both yes and head have exited:
Does it affect the termination of other programms that are taking STDIN? e.g. piping into vim etc?
I am also not sure but I tentatively think that it may be a race condition that we only see when the pager is holding the pipeline open. For example, I cannot reproduce it like this:
[EDIT: The -S flag is creeping in there because I used less instead of ^less and it picked up an alias that adds the -S flag. I don't think this detail is relevant to our main discussion; I've tried with and without -S and bug behavior is the same. ]
~/tmp/3p/nushell/nushell main 〉lsof -p 57766
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nu 57766 ddavison cwd DIR 1,5 3904 341671 /Users/ddavison
nu 57766 ddavison txt REG 1,5 22951464 129779054 /Users/ddavison/tmp/3p/nushell/nushell/target/release/nu
nu 57766 ddavison txt REG 1,5 2177216 1152921500312782999 /usr/lib/dyld
nu 57766 ddavison 0u CHR 16,0 0t189626 2079 /dev/ttys000
nu 57766 ddavison 1u CHR 16,0 0t189626 2079 /dev/ttys000
nu 57766 ddavison 2u CHR 16,0 0t189626 2079 /dev/ttys000
nu 57766 ddavison 3 PIPE 0x179ee492cdf0885b 16384 ->0x8c82085da032fb8b
nu 57766 ddavison 4 PIPE 0x8c82085da032fb8b 16384 ->0x179ee492cdf0885b
nu 57766 ddavison 5u KQUEUE count=0, state=0x8
nu 57766 ddavison 6u unix 0x2686700d9a19e0cb 0t0 ->0x2686700d9a19e25b
nu 57766 ddavison 7u unix 0x2686700d9a19e25b 0t0 ->0x2686700d9a19e0cb
nu 57766 ddavison 8 PIPE 0xb582f8ec54d853ac 65536 ->0xab685d34ebfb3dc2
nu 57766 ddavison 10 PIPE 0x2d0f57a7ee0fa87d 65536 ->0xb19b1f9c610c76eb
Piping into fzf appears to trigger a similar bug as piping into less, e.g.
^yes | ^head -n 999 | ^fzf
hangs on my Mac, and also similar problems have been reported piping content into fzf on ArchLinux (#6534) and in #6516 (OS TBD).
(On a Mac I can reproduce the same less problem by piping into git, bat, and delta, which is expected since all those programs invoke less as their pager.)
I've confirmed that the less and fzf problems are fixed on my MacOS machine by reverting 1d18f69.
Activity
sholderbach commentedon Sep 6, 2022
Does it affect the termination of other programms that are taking STDIN? e.g. piping into vim etc?
WindSoilder commentedon Sep 7, 2022
Maybe, but currently I'm not sure about that...
dandavison commentedon Sep 7, 2022
I believe that the bug involves processes in the pipeline terminating before we expect them to.
When we do
^yes | LESS= ^less, then this works correctly: it quits onq. Before quitting, the process tree shows thatyesis still running:GOOD:
However, when an additional process is present in the pipeline, such as
^yes | ^head -n 999 | LESS= ^lessthen it does not quit onqand the process tree shows that bothyesandheadhave exited:BAD:
The above commands are very consistent for me, but with other commands the bug sometimes appears and sometimes doesn't.
Another thing I don't understand is that
^yes | ^cat | LESS= ^lessseems to work fine, but what's the difference betweencatandhead?GOOD:
dandavison commentedon Sep 7, 2022
I am also not sure but I tentatively think that it may be a race condition that we only see when the pager is holding the pipeline open. For example, I cannot reproduce it like this:
GOOD:
(In addition to
less, this bug also affects programs likebatanddeltathat pipe their output tolessautomatically.)WindSoilder commentedon Sep 7, 2022
One more thing unfortunally, since the relative implementation is mostly based on ion(https://gitlab.redox-os.org/redox-os/ion), I tried and found that ion also had this problem...
sholderbach commentedon Sep 7, 2022
Would you mind dumping the file descriptors that the involved processes hold when they are stalled with
lsof -p <PID of process>dandavison commentedon Sep 7, 2022
Of course, no problem.
GOOD (
yesis alive in the pipeline andqwill work):[EDIT: The
-Sflag is creeping in there because I usedlessinstead of^lessand it picked up an alias that adds the-Sflag. I don't think this detail is relevant to our main discussion; I've tried with and without-Sand bug behavior is the same. ]dandavison commentedon Sep 7, 2022
BAD: (
yeshas exited andqwill not work)dandavison commentedon Sep 10, 2022
Piping into
fzfappears to trigger a similar bug as piping into less, e.g.hangs on my Mac, and also similar problems have been reported piping content into
fzfon ArchLinux (#6534) and in #6516 (OS TBD).(On a Mac I can reproduce the same
lessproblem by piping intogit,bat, anddelta, which is expected since all those programs invokelessas their pager.)I've confirmed that the
lessandfzfproblems are fixed on my MacOS machine by reverting 1d18f69.sophiajt commentedon Sep 11, 2022
Fixed with #6542