implemented process_wait()