Glances hang when killing process with muliple CTRL-C #3264

This commit is contained in:
nicolargo 2025-08-15 18:53:03 +02:00
parent 89e9ad1284
commit 2a3046796b
3 changed files with 19 additions and 7 deletions

View File

@ -52,10 +52,10 @@ if psutil_version_info < psutil_min_version:
# Trac malloc is only available on Python 3.4 or higher
def __signal_handler(signal, frame):
logger.debug(f"Signal {signal} caught")
def __signal_handler(sig, frame):
logger.debug(f"Signal {sig} caught")
# Avoid Glances hang when killing process with muliple CTRL-C See #3264
signal.signal(signal.SIGINT, signal.SIG_IGN)
end()
@ -188,3 +188,12 @@ def main():
# Glances can be ran in standalone, client or server mode
start(config=core.get_config(), args=core.get_args())
start(config=core.get_config(), args=core.get_args())
start(config=core.get_config(), args=core.get_args())
start(config=core.get_config(), args=core.get_args())
start(config=core.get_config(), args=core.get_args())
start(config=core.get_config(), args=core.get_args())
start(config=core.get_config(), args=core.get_args())
start(config=core.get_config(), args=core.get_args())
start(config=core.get_config(), args=core.get_args())
start(config=core.get_config(), args=core.get_args())

View File

@ -397,6 +397,10 @@ class _GlancesCurses:
logger.info("Stop Glances client and return to the browser")
else:
logger.info(f"Stop Glances (keypressed: {self.pressedkey})")
# End the curses window
self.end()
# Exit the program
sys.exit(0)
def _handle_refresh(self):
glances_processes.reset_internal_cache()

View File

@ -10,6 +10,7 @@
import curses
import math
import sys
from glances.logger import logger
from glances.outputs.glances_curses import _GlancesCurses
@ -49,7 +50,6 @@ class GlancesCursesBrowser(_GlancesCurses):
self._page_max = 0
self._page_max_lines = 0
self.is_end = False
self._revesed_sorting = False
self._stats_list = None
@ -157,8 +157,7 @@ class GlancesCursesBrowser(_GlancesCurses):
# 'ESC'|'q' > Quit
self.end()
logger.info("Stop Glances client browser")
# sys.exit(0)
self.is_end = True
sys.exit(0)
elif self.pressedkey == 10:
# 'ENTER' > Run Glances on the selected server
self.active_server = self._current_page * self._page_max_lines + self.cursor_position