finished process_wait, untested