mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-01 14:35:29 +00:00
[1858] refactoring: unify the SIGTERM/KILL cases into a single helper method.
This commit is contained in:
@@ -693,31 +693,34 @@ class BoB:
|
|||||||
# from doing so
|
# from doing so
|
||||||
if not self.nokill:
|
if not self.nokill:
|
||||||
# next try sending a SIGTERM
|
# next try sending a SIGTERM
|
||||||
components_to_stop = list(self.components.values())
|
self.__terminate_children(False)
|
||||||
for component in components_to_stop:
|
# finally, send SIGKILL (unmaskable termination) until everybody
|
||||||
logger.info(BIND10_SEND_SIGTERM, component.name(), component.pid())
|
# dies
|
||||||
try:
|
|
||||||
component.kill()
|
|
||||||
except OSError:
|
|
||||||
# ignore these (usually ESRCH because the child
|
|
||||||
# finally exited)
|
|
||||||
pass
|
|
||||||
# finally, send SIGKILL (unmaskable termination) until everybody dies
|
|
||||||
while self.components:
|
while self.components:
|
||||||
# XXX: some delay probably useful... how much is uncertain
|
# XXX: some delay probably useful... how much is uncertain
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
self.reap_children()
|
self.reap_children()
|
||||||
components_to_stop = list(self.components.values())
|
self.__terminate_children(True)
|
||||||
for component in components_to_stop:
|
logger.info(BIND10_SHUTDOWN_COMPLETE)
|
||||||
logger.info(BIND10_SEND_SIGKILL, component.name(),
|
|
||||||
component.pid())
|
def __terminate_children(self, forceful):
|
||||||
|
'''Terminate remaining subprocesses by sending a signal.
|
||||||
|
|
||||||
|
The forceful paramter will be passed Component.kill().
|
||||||
|
This is a dedicated subroutine of shutdown(), just to unify two
|
||||||
|
similar cases.
|
||||||
|
|
||||||
|
'''
|
||||||
|
logmsg = BIND10_SEND_SIGKILL if forceful else BIND10_SEND_SIGTERM
|
||||||
|
# TODO: we should be able to skip list()
|
||||||
|
for component in list(self.components.values()):
|
||||||
|
logger.info(logmsg, component.name(), component.pid())
|
||||||
try:
|
try:
|
||||||
component.kill(True)
|
component.kill(forceful)
|
||||||
except OSError:
|
except OSError:
|
||||||
# ignore these (usually ESRCH because the child
|
# ignore these (usually ESRCH because the child
|
||||||
# finally exited)
|
# finally exited)
|
||||||
pass
|
pass
|
||||||
logger.info(BIND10_SHUTDOWN_COMPLETE)
|
|
||||||
|
|
||||||
def _get_process_exit_status(self):
|
def _get_process_exit_status(self):
|
||||||
return os.waitpid(-1, os.WNOHANG)
|
return os.waitpid(-1, os.WNOHANG)
|
||||||
|
Reference in New Issue
Block a user