mirror of
https://github.com/altlinux/gpupdate.git
synced 2025-03-22 02:50:32 +03:00
Merge pull request #39 from altlinux/initial_signal_handling
Initial signal handling tested.
This commit is contained in:
commit
c383631fde
@ -20,6 +20,7 @@
|
||||
import argparse
|
||||
import logging
|
||||
import os
|
||||
import signal
|
||||
|
||||
from backend import backend_factory
|
||||
from frontend.frontend_manager import frontend_manager, determine_username
|
||||
@ -35,6 +36,7 @@ from util.arguments import (
|
||||
set_loglevel
|
||||
)
|
||||
from util.logging import slogm
|
||||
from util.signals import signal_handler
|
||||
|
||||
def parse_arguments():
|
||||
arguments = argparse.ArgumentParser(description='Generate configuration out of parsed policies')
|
||||
@ -128,5 +130,6 @@ def main():
|
||||
controller.run()
|
||||
|
||||
if __name__ == "__main__":
|
||||
signal.signal(signal.SIGINT, signal_handler)
|
||||
main()
|
||||
|
||||
|
@ -24,6 +24,7 @@ import os
|
||||
import sys
|
||||
import logging
|
||||
import pwd
|
||||
import signal
|
||||
|
||||
from util.users import (
|
||||
is_root
|
||||
@ -36,6 +37,7 @@ from util.dbus import (
|
||||
is_oddjobd_gpupdate_accessible,
|
||||
dbus_runner
|
||||
)
|
||||
from util.signals import signal_handler
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
|
||||
@ -155,5 +157,6 @@ def main():
|
||||
return int(ExitCodeUpdater.EXIT_SUCCESS)
|
||||
|
||||
if __name__ == '__main__':
|
||||
signal.signal(signal.SIGINT, signal_handler)
|
||||
sys.exit(int(main()))
|
||||
|
||||
|
@ -84,4 +84,5 @@ class ExitCodeUpdater(IntEnum):
|
||||
FAIL_NO_RUNNER = 1
|
||||
FAIL_GPUPDATE_COMPUTER_NOREPLY = 2
|
||||
FAIL_GPUPDATE_USER_NOREPLY = 3
|
||||
EXIT_SIGINT = 130
|
||||
|
||||
|
31
gpoa/util/signals.py
Normal file
31
gpoa/util/signals.py
Normal file
@ -0,0 +1,31 @@
|
||||
#
|
||||
# GPOA - GPO Applier for Linux
|
||||
#
|
||||
# Copyright (C) 2019-2020 BaseALT Ltd.
|
||||
#
|
||||
# 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import signal
|
||||
from sys import exit
|
||||
|
||||
from .arguments import ExitCodeUpdater
|
||||
|
||||
default_handler = signal.getsignal(signal.SIGINT)
|
||||
|
||||
def signal_handler(sig_number, frame):
|
||||
# Ignore extra signals
|
||||
signal.signal(sig_number, signal.SIG_IGN)
|
||||
print('Received signal, exiting gracefully')
|
||||
exit(ExitCodeUpdater.EXIT_SIGINT)
|
||||
|
Loading…
x
Reference in New Issue
Block a user