Additional functionality in process_wait. Not working commit.