X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=python%2Fovs%2Ffatal_signal.py;h=b931512689e7e06a24c96cb6414b9999db616caf;hb=e7ed3a3a5f87d20f0cc632ae23adba6f30a4e19d;hp=5fca820e6a766399c4c32704e2f2b6d3124ecda5;hpb=991559357f6a03c3a5b70c053c8c2554aa8d5ee4;p=openvswitch diff --git a/python/ovs/fatal_signal.py b/python/ovs/fatal_signal.py index 5fca820e..b9315126 100644 --- a/python/ovs/fatal_signal.py +++ b/python/ovs/fatal_signal.py @@ -1,4 +1,4 @@ -# Copyright (c) 2010 Nicira Networks +# Copyright (c) 2010, 2011 Nicira Networks # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,24 +17,10 @@ import logging import os import signal -_inited = False _hooks = [] -def _init(): - global _inited - if not _inited: - _inited = True - - for signr in (signal.SIGTERM, signal.SIGINT, - signal.SIGHUP, signal.SIGALRM): - if signal.getsignal(signr) == signal.SIG_DFL: - signal.signal(signr, _signal_handler) - atexit.register(_atexit_handler) - def add_hook(hook, cancel, run_at_exit): _init() - - global _hooks _hooks.append((hook, cancel, run_at_exit)) def fork(): @@ -119,3 +105,15 @@ def _call_hooks(signr): for hook, cancel, run_at_exit in _hooks: if signr != 0 or run_at_exit: hook() + +_inited = False +def _init(): + global _inited + if not _inited: + _inited = True + + for signr in (signal.SIGTERM, signal.SIGINT, + signal.SIGHUP, signal.SIGALRM): + if signal.getsignal(signr) == signal.SIG_DFL: + signal.signal(signr, _signal_handler) + atexit.register(_atexit_handler)