Skip to content

Commit

Permalink
Improve kill signal management #2194
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolargo committed Mar 21, 2023
1 parent cfca339 commit e60c976
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions glances/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@


def __signal_handler(signal, frame):
"""Callback for CTRL-C."""
logger.debug("Signal {} catched".format(signal))
end()


Expand All @@ -74,7 +74,7 @@ def end():
# ...after starting the server mode (issue #1175)
pass

logger.info("Glances stopped (key pressed: CTRL-C)")
logger.info("Glances stopped gracefully")

# The end...
sys.exit(0)
Expand Down Expand Up @@ -156,8 +156,9 @@ def main():
Select the mode (standalone, client or server)
Run it...
"""
# Catch the CTRL-C signal
signal.signal(signal.SIGINT, __signal_handler)
# Catch the kill signal
for sig in (signal.SIGTERM, signal.SIGINT, signal.SIGHUP):
signal.signal(sig, __signal_handler)

# Log Glances and psutil version
logger.info('Start Glances {}'.format(__version__))
Expand Down

0 comments on commit e60c976

Please sign in to comment.