-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ugrep
does not handle procfs
pseudofiles correctly
#350
Comments
Two things to consider:
|
There are different approaches possible, each with some caveats:
|
The following table clarifies when a search is performed. Note that GNU/BSD grep have changed over the years on how special files are dealt with e.g. when recursing open them as nonblocking. Searching depends on Recurse, -Dread, Regular File if the regular file is Empty. For ugrep 4.5 we have: Note that Recurse means option An alternative approach is to perform a search for scenario N N Y Y with the possibility of getting blocked, so the recursive case Y N Y Y opens the file nonblocking. Likewise for N Y Y Y and Y Y Y Y. The first two red N in the table describe your case. The first without -Dread which ugrep does not set by default, but GNU grep does, and the second is with -Dread. The second red N should really be a Y actually. So this should be changed in the next release. Perhaps the Alternative in this table is preferable: When recursing we never block. When not recursing we do not block on empty files (procfs files) unless |
Finishing up work on release 5 to include the proc FS handling changes in the Alternative table above, pending testing. |
Thanks so much for this work! |
When I want to see mount options for a filesystem, I typically query
/proc/mounts
like so:This does not work with
ugrep
, which returns nothing and exits with a status of1
for the same query:However, it returns the results as expected when
cat
abuse is introduced:cat /proc/mounts | ugrep btrfs
Shell redirection also yields results as expected:
ugrep btrfs < /proc/mounts
The text was updated successfully, but these errors were encountered: