Bug 11626

Summary: Recursive grep hangs when encountering a named pipe
Product: Busybox Reporter: whitedavidp
Component: OtherAssignee: unassigned
Status: NEW ---    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Other   
Host: Target:
Build:

Description whitedavidp 2019-01-21 20:25:00 UTC
I am using BB 1.29.2 on Android and recently encountered a situation when a recursive grep command was hanging. I discovered that in the folder/file tree being recursed there were several files which ls -l shows having a file type of "p", named pipe.

I can understand why this might cause a problem. But it seems that it might be a good idea for grep to check the file type and not even attempt to open/process such files. One would think that this would at least create a file open/read error given that there is the -s option for suppressing output of this nature. But all I get is a hung grep that must be manually killed.

I know how to avoid this using something like this:

     find . -type f -exec grep pattern {}

But this seems far less efficient than having grep the files it intends to try and open.

Thanks very much!