-
-
Notifications
You must be signed in to change notification settings - Fork 750
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
[preview-tui] updated tree breaks preview file/dir list #1291
Comments
Seems like It's not there on master and I have no idea how it could be caused by updating, The issue is also not present for me on |
Didn't even think to try another terminal. Tried kitty, it's fine, so it's foot that's the issue. /sigh |
This issue seems not to be limited to preview-tui. tree works fine in both xterm and urxvt without nnn |
This is, as far as I know, not a standardized file descriptor (like stdin/stdout/stderr), but rather something made up by In my case, tree-under-zsh-under-nnn has an inotify descriptor opened at FD 3. As far as I can tell, it's The following wrapper script shows that FD 3 is the cause of all this (it closes FD 3 and then exec's #!/usr/bin/bash
exec 3>&-
exec tree |
Line 8635 in 23b54ba
Should probably set |
I don't use tree nor am I familiar with it's codebase, but what you're describing sounds like it is something that should be addressed by tree's upstream rather than us trying to hack around it. |
I certainly don't agree with tree's implementation. But with that said, you never exec other programs with file-descriptors other than stdin/stdout/stderr open. Unless it's intended. I.e. you are passing an FD to the child on purpose. But this; an inotify FD used by nnn itself, should not be passed to the shell. Closing your own file-descriptors before exec:ing a child is not "hacking around it". It's what you're supposed to do. |
@dnkl I didn't pay attention to your other post and was under the impression you were proposing using that bash script as a solution. Sorry for the confusion. |
No worries, and I hope I didn't come off as being rude. The bash script was only meant as a way to show/prove that the leaked FD is the cause, and I could have been more clear about that. |
Thank you very much for checking this in such depth, dnkl. |
imho, Not sure if it leaks other file descriptors as well; one can either inspect the nnn source code, and ensure all opened file descriptors have |
Making thousands of syscall in a loop sounds like a really bad idea. Using I'm at the end of my awake hours though. We can pick this up tomorrow, or someone else wants to take a crack then feel free to do so. |
@badxnach @dnkl does this fix the issue with tree? diff --git a/src/nnn.c b/src/nnn.c
index a0fafe9..a6491bd 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -8629,7 +8629,7 @@ int main(int argc, char *argv[])
#ifdef LINUX_INOTIFY
/* Initialize inotify */
- inotify_fd = inotify_init1(IN_NONBLOCK);
+ inotify_fd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
if (inotify_fd < 0) {
xerror();
return EXIT_FAILURE; Skimmed through most of the Also just out of curiosity, any clue on what's going on here with kitty? @dnkl
|
Closes: jarun#1291 Co-authored-by: Daniel Eklöf <daniel@ekloef.se>
Patch works for me as well, thanks!
Regarding kitty; I've no idea - for me, tree breaks in kitty as well, in exactly the same way (and is fixed by the patch).
|
Kitty does loop and close FDs in the range 3-200 when exec:ing its child process.
But that means it only applies to the first shell instance; when nnn runs, and when nnn exec's a plugin, kitty is not involved in the process, and no FDs are closed. Unless nnn spawns a new kitty instance when you start a shell from it (it doesn't for me).
|
on arch, Version 2.0.2 (02/16/2022) |
That's definitely the right move. 😄 |
Closes: jarun#1291 Co-authored-by: Daniel Eklöf <daniel@ekloef.se>
Environment details (Put
x
in the checkbox along with the information)nnn
masterArch Linux with tree 2.0.1-2, using preview-tui script, now file/dir listings don't display correctly anymore. See [1]
Running the same tree command that preview-tui uses, in a shell, it still works. See [2]
Downgrading to 1.8.0-2 fixes, as expected.
[1] https://0x0.st/ooQa.png
[2] https://0x0.st/ooQB.png
The text was updated successfully, but these errors were encountered: