def _wait_service(self):
"""Return the last died service or None"""
try:
# Don't block if no child processes have exited
pid, status = os.waitpid(0, os.WNOHANG)
if not pid:
return None
except OSError as exc:
if exc.errno not in (errno.EINTR, errno.ECHILD):
raise
return None
if os.WIFSIGNALED(status):
sig = SIGNAL_TO_NAME.get(os.WTERMSIG(status))
LOG.info('Child %(pid)d killed by signal %(sig)s',
dict(pid=pid, sig=sig))
else:
code = os.WEXITSTATUS(status)
LOG.info('Child %(pid)d exited with status %(code)d',
dict(pid=pid, code=code))
for conf in self._running_services:
if pid in self._running_services[conf]:
return conf, self._running_services[conf].pop(pid)
LOG.error('pid %d not in service list', pid)
评论列表
文章目录