Skip to content
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

CPU using %100 by nnn #225

Closed
abdyek opened this issue Mar 16, 2019 · 17 comments
Closed

CPU using %100 by nnn #225

abdyek opened this issue Mar 16, 2019 · 17 comments

Comments

@abdyek
Copy link

abdyek commented Mar 16, 2019

Hi,
I use nnn v2.3 on manjaro linux - i3.
It is running nnn at background when I close it.
https://postimg.cc/s11YZnQ4

@jarun
Copy link
Owner

jarun commented Mar 16, 2019

Please share the exact steps to reproduce.

@abdyek
Copy link
Author

abdyek commented Mar 16, 2019

Ohh.. sorry
Firstly, my english is not good so I am sorry for it
I use vim for programming. Folders of my projects are at /mnt/Depo/Project
I added export NNN_BMS='d:/mnt/Depo;p:/mnt/Depo/Projects;' to .bashrc file,
I prefer to go to my project folder using leader key + p and return shell with ! to open vim,
Sometimes I open nnn another terminal window and close it
What can I share info about this issue ?

@jarun
Copy link
Owner

jarun commented Mar 17, 2019

What can I share info about this issue ?

I couldn't reproduce your issue. So I need definite steps - how did you start nnn, what's your terminal emulator and shell. What did you do after starting nnn, basically a way to reproduce it on my setup locally so I can analyze the issue.

nnn kills itself if the parent process has exited so I have to know the steps when I guess this is not happening.

Also, please try on master and see if you are seeing the issue.

@abdyek
Copy link
Author

abdyek commented Mar 18, 2019

I use i3-wm, gnome-terminal, vim and manjaro linux than
I will explain it step by step

  • I opened a new gnome terminal using $mod key + enter
  • I started nnn with commant of "nnn"
  • I went to my bookmarks with leader key + p (export NNN_BMS='d:/mnt/Depo;p:/mnt/Depo/Projects;')
  • I returned shell with ! and started vim using "vim"
  • I worked in the terminal for a while
  • I opened new another terminal using $mod key + enter
  • I started nnn with commant of "nnn"
  • I used it and closed it

@jarun
Copy link
Owner

jarun commented Mar 18, 2019

OK.

I worked in the terminal for a while

did you quit vim and nnn or left vim open?

I used it and closed it

what is it? Used the terminal and closed it directly? Did you quit nnn?

@jarun
Copy link
Owner

jarun commented Mar 18, 2019

I have tried to reproduce it using your steps and directly closing the terminal (xfce4-terminal) at the points I noted above. However, I do not see the issue. In both the cases nnn quits when I close the terminal directly.

Can you try this on the latest release v2.4?

@jarun
Copy link
Owner

jarun commented Mar 23, 2019

Please revert back when you have more info.

@jarun jarun closed this as completed Mar 23, 2019
@cowabungadude69
Copy link

cowabungadude69 commented Apr 23, 2019

Here's a simple way to recreate it I think.

  • open a terminal
  • start nnn
  • enter shell with !
  • start nnn in that shell
  • close the terminal

Tried this on two machines with simple terminal and bash.

@jarun
Copy link
Owner

jarun commented Apr 23, 2019

I will look into it.

@jarun
Copy link
Owner

jarun commented Apr 23, 2019

@cowabungadude69 thanks for the steps. I could reproduce the issue with st and terminator.

The issue happens due to the following deadlock:

nnn keeps checking if the parent has exited. However, when it spawns a child it waits (blocks) for the child to exit and can't check if its parent has exited. The child on the other hand, doesn't quit because it's parent hasn't exited.

I have fixed it. Please test and confirm the patch.

jarun added a commit that referenced this issue Apr 23, 2019
@cowabungadude69
Copy link

Yep, no problems here. Thank you.

@jarun
Copy link
Owner

jarun commented Apr 25, 2019

@cowabungadude69 I believe I have to pull back patch 32dde33 and document as a known issue. The problem with polling on waitpid is whenever a child process is spawned, the parent nnn process uses 100% memory.

This is a serious problem. In case of the scenario you reported, the terminal is closed with a nested nnn instance and it can be easily avoided (by not closing the terminal directly without closing a running nnn instance). However the fix is going to affect every user who spawns a child process.

@jarun jarun added the wontfix label Apr 25, 2019
jarun added a commit that referenced this issue Apr 25, 2019
This reverts commit 32dde33.
jarun added a commit that referenced this issue Apr 25, 2019
@borestad
Copy link

borestad commented May 28, 2019

How bad of a fix would it be to spawn a helper process that looks if nnn is still running - but not in TTY-mode anymore - and then kill the main process and itself?

@borestad
Copy link

Some reference to ncdu that I think might have the same issue

rofl0r/ncdu@cbe24d6

@jarun
Copy link
Owner

jarun commented May 28, 2019

Update: this issue is fixed now!

I will leave it as a known issue as documented currently. The time taken to confirm any elaborate mechanism on all supported platforms is significant and I would rather add a useful feature if I get the time instead.

@KlzXS KlzXS mentioned this issue Aug 18, 2019
3 tasks
@jarun jarun removed the wontfix label Aug 19, 2019
@jarun
Copy link
Owner

jarun commented Aug 19, 2019

@abdyek @cowabungadude69 @borestad this issue is now fixed.

@jarun jarun mentioned this issue Sep 3, 2019
4 tasks
@jarun jarun mentioned this issue Sep 21, 2019
5 tasks
@jarun jarun mentioned this issue Oct 6, 2019
3 tasks
@jcguu95
Copy link

jcguu95 commented Dec 20, 2019

Off topic.. but I appreciate watching you fixing problems! Thanks for great work!

@lock lock bot locked and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants