Files
RedBear-OS/local
vasilito 5fdfa4384c sessiond: reap inhibitors when caller FD closes (logind contract)
The 5-lane review flagged that sessiond inhibitors were reaped only on
bus-owner disappearance (via NameOwnerChanged polling). The logind
contract requires the inhibitor to be released when the returned FD
is closed — regardless of whether the bus connection survives. This
commit closes that gap.

- Add InhibitorEntry.inhibitor_fd: Option<OwnedFd> tracking the
  caller-side FD the daemon sent back.
- Add manager::remove_inhibitor_for_fd(fd) that scans inhibitors for a
  matching caller FD and removes the matching entry, closing the
  daemon-side FD copy.
- In Inhibit(), spawn a tokio task that polls the caller-side FD for
  POLLHUP via nix::poll::poll. When the caller closes their end, the
  task calls remove_inhibitor_for_fd(fd) to drop the entry. Uses tokio
  (already a dependency).
- nix is already an existing dependency via libredox-transitive;
  use only poll() and PollFd which are stdlib-adjacent. If nix is not
  available, fall back to a no-op (the NameOwnerChanged reaper remains
  the fallback for lost-bus-owner cleanup).

Verified by host cargo test: 63/63 tests pass, including 3 new tests:
  - closing_caller_fd_removes_inhibitor
  - multiple_inhibitors_same_sender_independent_fd_close
  - inhibitor_fd_closure_does_not_affect_other_sender
2026-07-28 07:19:51 +09:00
..