def _pids_holding_file()

in dcrpm/pidutil.py [0:0]


def _pids_holding_file(lsof, path):
    # type: (str, str) -> t.Set[int]
    try:
        proc = run_with_timeout(
            [lsof, "-F", "p", path], LSOF_TIMEOUT, raise_on_nonzero=False
        )
    except DcRPMException:
        logger.warning("lsof timed out")
        return set()

    if proc.returncode != StatusCode.SUCCESS and proc.stderr:
        # `lsof` has pretty coarse error reporting. Returning nonzero means either
        # nothing matched or something went wrong. If nothing matches stderr will
        # be empty; if it contains output then assume something went wrong (though
        # "wrong" could be a fairly benign warning, like `path` not existing).
        logger.warning("lsof returned non-zero: %s", proc.stderr)

    return {int(line[1:]) for line in proc.stdout.splitlines() if line.startswith("p")}