def procs_holding_file()

in dcrpm/pidutil.py [0:0]


def procs_holding_file(path):
    # type: (str) -> t.Set[psutil.Process]
    """
    Return a set of processes holding `path` open by using `lsof`. `lsof` is slower but
    will find processes that have other links to the same inode open.
    """
    lsof = which("lsof")
    if lsof is None:
        raise DcRPMException("Couldn't find `lsof` binary")

    procs = [process(pid) for pid in _pids_holding_file(lsof, path)]
    return set(filter(None, procs))