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

Improve kill signal management #2194

Closed
ChillarAnand opened this issue Nov 16, 2022 · 7 comments
Closed

Improve kill signal management #2194

ChillarAnand opened this issue Nov 16, 2022 · 7 comments
Labels
Milestone

Comments

@ChillarAnand
Copy link

ChillarAnand commented Nov 16, 2022

Describe the bug
Initially I found glances was consuming 100% CPU and thought it was a performance issue. Later I found that it is stale process.

To Reproduce

When glances is run in the terminal interactively, if CTRL + C is used to quit glances or when the terminal is closed forcefully, once in a while a stale process is left behind. I am not able to reproduce it consistently. I have been using glances from years but I am seeing this issue only from few weeks.

Expected behavior
No stale process should be there.

Desktop (please complete the following information):

$ glances --issue         
=====================================================================================================================================================================================
Glances 3.3.0.4 (/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/glances/__init__.py)
Python 3.9.12 (/Library/Frameworks/Python.framework/Versions/3.9/bin/python)
PsUtil 5.9.1 (/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/psutil/__init__.py)
=====================================================================================================================================================================================
alert         [OK]    0.00007s []
amps          [OK]    0.00026s []
cloud         [OK]    0.00008s {}
connections   [OK]    0.00024s {}
core          [OK]    0.00017s {'phys': 8, 'log': 8}
cpu           [OK]    0.00043s {'total': 26.1, 'user': 3.1, 'nice': 0.0, 'system': 2.5, 'idle': 94.5, 'time_since_update': 2.038684129714966, 'cpucore': 8, 'ctx_switches':
diskio        [OK]    0.00155s key=disk_name [{'time_since_update': 2.0400052070617676, 'disk_name': 'disk0', 'read_count': 4, 'write_count': 1, 'read_bytes': 32768, 'writ
docker        [OK]    0.00006s []
folders       [OK]    0.00006s []
fs            [OK]    0.00108s key=mnt_point [{'device_name': '/dev/disk3s1s1', 'fs_type': 'apfs', 'mnt_point': '/', 'size': 494384795648, 'used': 381701836800, 'free': 11
gpu           [OK]    0.00003s []
help          [OK]    0.00001s None
ip            [OK]    0.00007s {}
irq           [OK]    0.00004s []
load          [OK]    0.00006s {'min1': 3.58837890625, 'min5': 9.4169921875, 'min15': 5.4912109375, 'cpucore': 8}
mem           [OK]    0.00011s {'total': 8589934592, 'available': 3487072256, 'percent': 59.4, 'used': 5102862336, 'free': 3487072256, 'active': 3453976576, 'inactive': 33
memswap       [OK]    0.00013s {'total': 0, 'used': 0, 'free': 0, 'percent': 0.0, 'sin': 3070083072, 'sout': 14827520, 'time_since_update': 2.043797016143799}
network       [OK]    0.00226s key=interface_name [{'interface_name': 'lo0', 'alias': None, 'time_since_update': 2.0129363536834717, 'cumulative_rx': 335872, 'rx': 0, 'cum
now           [OK]    0.00003s 2022-11-16 15:37:10 IST
percpu        [OK]    0.00009s key=cpu_number [{'key': 'cpu_number', 'cpu_number': 0, 'total': 92.0, 'user': 0.0, 'system': 1.0, 'idle': 8.0, 'nice': 0.0}, {'key': 'cpu_nu
ports         [OK]    0.00031s []
processcount  [OK]    0.03994s {'total': 405, 'running': 405, 'sleeping': 0, 'thread': 794, 'pid_max': 0}
processlist   [OK]    0.00017s key=pid [{'gids': puids(real=20, effective=20, saved=20), 'memory_percent': 2.0017623901367188, 'pid': 378, 'cpu_percent': 4.8, 'cpu_times':
psutilversion [OK]    0.00004s (5, 9, 1)
quicklook     [OK]    0.00008s {'cpu': 26.1, 'percpu': [{'key': 'cpu_number', 'cpu_number': 0, 'total': 92.0, 'user': 0.0, 'system': 1.0, 'idle': 8.0, 'nice': 0.0}, {'key'
raid          [OK]    0.00001s {}
sensors       [OK]    0.00000s key=label [{'label': 'Battery', 'value': 58, 'unit': '%', 'status': 'Discharging', 'type': 'battery', 'key': 'label'}]
smart         [NA]
system        [OK]    0.00000s {'os_name': 'Darwin', 'hostname': 'Anands-MacBook-Air.local', 'platform': '64bit', 'os_version': '13.0.1', 'hr_name': 'Darwin 13.0.1 64bit'}
uptime        [OK]    0.00002s {'seconds': 206}
wifi          [OK]    0.00001s []
=====================================================================================================================================================================================
Total time to update all stats: 0.05213s
=============================================================================================================================================================================== 3.18s


Additional context

Screenshot 2022-11-16 at 12 27 34

As a temporary workaround, I am running glances using the following command.

$ sudo pkill -f glances; sudo glances --theme-white --process-short-name --byte -t 4 --config ~/glances.conf                                                                       
@nicolargo
Copy link
Owner

@ChillarAnand thanks for the issue report.

Anything in the Glances log file ?

@ChillarAnand
Copy link
Author

There are couple of exceptions and error messages. But I am not sure if they are related.

Posted entire log here. https://gist.github.com/ChillarAnand/07e61f31cf89d794cb9615b4e1210399.

@ChillarAnand
Copy link
Author

Steps to reproduce:

Open new tab in terminal.
Run glances with sudo.
Without quitting glances, close the terminal.

I think terminal is trying to close glances. Since glances was started with sudo, it is not able to kill the process.

It works fine, if we run glances without sudo.

@RazCrimson
Copy link
Collaborator

@ChillarAnand
I can't reproduce this on my end using Konsole on Arch Linux.

Could you just confirm if you are able to reproduce the issue with maybe another terminal manager?

@ChillarAnand
Copy link
Author

@RazCrimson I was experiencing this issue on Mac with the Terminal application.

Just tried with iTerm on Mac and I am not able to reproduce it.

@nicolargo
Copy link
Owner

@ChillarAnand i found the issue. When a terminal is closed, it sent a SIGHUP signal to the running process. Glances only catch the SIGINT signal.

Correction will be done on the develop branch.

Thanks for the issue report @ChillarAnand !

@nicolargo nicolargo added this to the Glances 3.4.0 milestone Mar 21, 2023
@nicolargo nicolargo changed the title Stale glances process is left behind Improve kill signal management Mar 21, 2023
nicolargo added a commit that referenced this issue Mar 21, 2023
@nicolargo
Copy link
Owner

Corrected on the develop branch.

Will be released in Glances 3.4.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants