Skip to content

proc_fd ¤

Helpers for walking /proc/*/fd to identify which processes share a given kernel object.

Currently used by procinfo to turn an anonymous pipe FD ("pipe:[N]") into a list of (pid, fd, comm, mode) endpoints. Like the SOCK_DIAG path this is inherently local-only — the data lives in the host kernel's procfs and means nothing for a remote / different-kernel target.

Classes:

  • Pipe

    Anonymous pipe FD as seen from one process.

Functions:

Pipe ¤

Pipe()

Anonymous pipe FD as seen from one process.

inode and fd describe our own end. mode is "r"/"w"/"rw"/"?" derived from /proc/PID/fdinfo. peers lists every other FD across the system that points at the same pipe inode, with the same mode info, so the user can see who's on the other end (or that they hold both ends themselves).

Methods:

Attributes:

  • inode (int | None) –
  • fd (int | None) –
  • mode (str | None) –
  • peers (list[tuple[int, int, str, str]]) –

inode class-attribute instance-attribute ¤

inode: int | None = None

fd class-attribute instance-attribute ¤

fd: int | None = None

mode class-attribute instance-attribute ¤

mode: str | None = None

peers instance-attribute ¤

peers: list[tuple[int, int, str, str]] = []

__str__ ¤

__str__() -> str

__repr__ ¤

__repr__() -> str

find_pipe_endpoints ¤

find_pipe_endpoints(
    target_inodes: set[int],
) -> dict[int, list[tuple[int, int, str, str]]]

For each pipe inode in target_inodes, return all FDs holding it.

Result maps inode -> list of (pid, fd, comm, mode) sorted by (pid, fd) for determinism. Inodes with no discoverable holder are absent (the kernel may report a pipe inode that's only held by a process whose /proc/PID/fd we can't read).

Permission errors on individual processes are ignored — this is best effort, the same way lsof is for non-root users.