def wait(processes):
    """waits on a list of processes"""
    while processes:
        for p in processes:
            if p.poll() is not None:
                print('Process {} ({}) ended with exit code {}'.format(p.
                    desc, p.pid, p.returncode))
                processes.remove(p)
