Repository navigation
Conversation
The tty of a process is now read from /proc/<pid>/stat and stored as a full device path like /dev/pts/0. The --terminal value was kept as typed, so "pgrep -t pts/0" or "pgrep -t tty1" never matched anything. Prepend /dev/ to the given name when it is missing. Fixes uutils#179
og-orca
marked this pull request as ready for review
November 30, 2026 17:27
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #866 +/- ##
==========================================
+ Coverage 19.20% 20.32% +1.12%
==========================================
Files 68 68
Lines 10156 10127 -29
Branches 546 551 +5
==========================================
+ Hits 1950 2058 +108
+ Misses 8206 8069 -137
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
sylvestre
reviewed
Nov 30, 2026
| fn try_from(value: &str) -> Result<Self, Self::Error> { | ||
| Self::try_from(PathBuf::from(value)) | ||
| let name = value.strip_prefix("/dev/").unwrap_or(value); | ||
| Self::try_from(PathBuf::from(format!("/dev/{name}"))) |
Contributor
There was a problem hiding this comment.
could be Ok(Self::Known(format!("/dev/{name}"))) directly, no?
no need to go through PathBuf and back to a String
Author
There was a problem hiding this comment.
Good point. The PathBuf only got turned back into a String, so I build the Known value directly now.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #179
Since #578, pgrep reads the tty from
/proc/<pid>/stat, so a normal user can see the tty of other users' processes. But the tty is stored as a full path (/dev/pts/0), while the-tvalue is kept as typed (pts/0). They never match, sopgrep -t pts/0orpgrep -t tty1prints nothing for anyone, root included.Now I add
/dev/to the-tvalue when it is missing.-t /dev/pts/0still works.Before (user
bob,sleeprunning asaliceon pts/0):After:
Testing:
test_teletype_from_name_without_dev_prefix. It fails on main (Known("pts/0")vsKnown("/dev/pts/0")) and passes now.alicerunsscript -qfc 'sleep 300',bobrunspgrep -t pts/0.cargo fmt --checkandcargo clippy --all-targets -- -D warningsare clean.Limits:
sniceuses the same parsing, so its-tgets the same change; I only checked that its tests still pass. In my containertest_cgroupfails, but it fails on main the same way.