Source code for libka.utils.simple_abort_handler
#!/usr/bin/python3
# pylint: disable=line-too-long
# kate: space-indent on; indent-width 4; replace-tabs on; indent-mode python; remove-trailing-space modified;
# vim: expandtab ts=4
# pylint: enable=line-too-long
############################################################################
# Copyright © 2018 José Manuel Santamaría Lema <panfaust@gmail.com> #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License, or #
# (at your option) any later version. #
############################################################################
"""This module just provides a `simple_abort_handler` function to exit nice"""
import sys
from libka.ka_print import ka_print_plain
[docs]
def simple_abort_handler(recv_signal, frame): # pylint: disable=unused-argument
"""
Simple signal handler for `Ctrl+C`.
It just prints an 'Aborted by user request' message and exits the program with code 130.
See http://www.tldp.org/LDP/abs/html/exitcodes.html for more information about exit codes.
"""
ka_print_plain('Aborted by user request')
sys.exit(130) #http://www.tldp.org/LDP/abs/html/exitcodes.html