wait for subprocess return code and remove tmp file if OK