Follow termination of our children only

This commit is contained in:
Mehdi Abaakouk 2016-08-03 00:50:39 +02:00
parent 972603c38b
commit af4dd073cd
1 changed files with 11 additions and 8 deletions

View File

@ -267,14 +267,17 @@ class ServiceManager(object):
os.killpg(0, signal.SIGTERM)
LOG.debug("Waiting services to terminate")
while True:
try:
os.waitpid(0, 0)
except OSError as e:
if e.errno == errno.ECHILD:
break
else:
raise
# NOTE(sileht): We follow the termination of our children only
# so we can't use waitpid(0, 0)
for conf in self._services:
for pid in self._running_services[conf]:
try:
os.waitpid(pid, 0)
except OSError as e:
if e.errno == errno.ECHILD:
pass
else:
raise
LOG.debug("Shutdown finish")
sys.exit(0)