def METHOD_NAME(process, progress_reporter: IProgressReporter):
    try:
        while process.poll() is None:
            try:
                process.wait(1)
            except:
                if progress_reporter.cancelled:
                    retcode = process.poll()
                    if retcode is None:
                        msg_str = f"Progress was cancelled (RCC pid: {process.pid} was killed).\n"
                        msg = msg_str.encode("utf-8")
                        log.info(msg_str)
                        stderr_contents.insert(0, msg)
                        stderr_contents.append(msg)
                        on_stderr(msg)
                        kill_process_and_subprocesses(process.pid)
    except:
        log.exception("Error checking that progress was cancelled.")