import time


def collect_host_processes(processes, done_functs=()):
    """Returns a summary of return codes for each process after
    they are all finished.
    
    done_functs: iter of functs
        Each function in done_functs will be executed with the args (processes, p)
        where p is the process that has just completed and processes is the list
        of remaining processes still (possibly) running.
    """
    summary = {}
    processes = processes[:]
    while len(processes) > 0:
        time.sleep(10)
        for p in processes:
            if p.exitcode is not None:
                summary[p.name] = p.exitcode
                processes.remove(p)
                for f in done_functs:
                    f(processes, p)
                break
            
    return summary