Skip to content

Conversation

@naoNao89
Copy link

@naoNao89 naoNao89 commented Oct 6, 2025

  • Read tty_nr from /proc/PID/stat (field 7) which is world-readable
  • Add TryFrom implementation to decode tty_nr device numbers
  • Fix Display impl bug that had wrong device name mappings
  • Update tty() method to use stat file first, fall back to fd scanning
  • Update all callers to use mutable borrow for tty() method

This fixes issue #179 where pgrep -t would fail when run as a normal user because /proc/PID/fd is only readable by the process owner.

@sylvestre
Copy link
Contributor

again, please stop with the AI generated comment 0
please take the time to write something for human

@cakebaker
Copy link
Contributor

I don't know if you have seen it: test_pgrep::test_terminal fails in the CI.

naoNao89 added a commit to naoNao89/procps that referenced this pull request Nov 2, 2025
Merge latest changes from origin/main which added euid check to
basic_collector for better process filtering. Kept mutable borrow
for tty() method as required by PR uutils#533.
naoNao89 added a commit to naoNao89/procps that referenced this pull request Nov 2, 2025
Remove unnecessary condition check in the match arm for virtual console
terminals. Both branches returned the same value, so the condition was
redundant. Addresses review feedback from PR uutils#533.
- Read tty_nr from /proc/PID/stat (field 7) which is world-readable
- Add TryFrom<u64> implementation to decode tty_nr device numbers
- Fix Display impl bug that had wrong device name mappings:
  * Tty now maps to /dev/tty{id} (was /dev/pts/{id})
  * TtyS now maps to /dev/ttyS{id} (was /dev/tty{id})
  * Pts now maps to /dev/pts/{id} (was /dev/ttyS{id})
- Update tty() method to use stat file first, fall back to fd scanning
- Update all callers to use mutable borrow for tty() method
- Simplify tty_nr decoding for major device 4 (review feedback)
- Fix implicit clone warning in process_matcher.rs

This fixes issue uutils#179 where pgrep -t would fail when run as a normal user
because /proc/PID/fd is only readable by the process owner.
@naoNao89 naoNao89 force-pushed the fix-tty-detection-issue-179 branch from e950008 to 0edd3e1 Compare November 3, 2025 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants