def reap_processes(self):
        # map watcher to pids
        watchers_pids = {}
        for watcher in self.iter_watchers():
            if not watcher.is_stopped():
                for process in watcher.processes.values():
                    watchers_pids[process.pid] = watcher

        # detect dead children
        if not IS_WINDOWS:
            while True:
                try:
                    # wait for our child (so it's not a zombie)
                    pid, status = os.waitpid(-1, os.WNOHANG)
                    if not pid:
                        break

                    if pid in watchers_pids:
                        watcher = watchers_pids[pid]
                        watcher.reap_process(pid, status)
                except __HOLE__ as e:
                    if e.errno == errno.EAGAIN:
                        sleep(0)
                        continue
                    elif e.errno == errno.ECHILD:
                        # process already reaped
                        return
                    else:
                        raise
dataset/ETHPy150Open circus-tent/circus/circus/arbiter.py/Arbiter.reap_processes