Description of problem: "grep -D skip ..." should skip FIFO, BLK and CHR files, and really shouldn't try to open them. Note also that "grep -d skip" should skip subdirectories, but doesn't. Version-Release number of selected component (if applicable): grep-2.5.1-52.2 How reproducible: 100% Steps to Reproduce: 0. Become root 1. mkdir /tmp/x 2. cd /tmp/x 3. mknod hdg8 b 34 8 4. mknod null c 1 3 5. mkfifo y 6. strace -eopen grep -D skip -r hello . 7. CTRL-C when it gets stuck opening the FIFO. And then: 9. grep -D skip -r hello . & sleep 3; echo hello >y Actual results: From step 6, the strace shows: ... open("./hdg8", O_RDONLY) = -1 ENXIO (No such device or address) ... open("./null", O_RDONLY) = 3 open("./y", O_RDONLY <unfinished ...> And from step 9: [1] 32746 grep: ./hdg8: No such device or address ./y:hello [1]+ Exit 2 grep -D skip -r hello . Note grep actually read from the FIFO, even though it was supposed to skip it. Expected results: grep should not have attempted to open FIFO, character device or block device files. It should also skip socket files according to the manual page and grep's --help dump. Additional info: grep might be able to use the type information passed by the getdents() system call under some circumstances. This is available through the libc readdir() function. If this information is not available, it should stat the files beforehand (fstatat() might be useful in the directory scanning case). It could then potentially dispense with the fstat() it does after opening the file. The main thing, I think, is that it shouldn't attempt to *open* one of these special files if -D skip is given to it.
Thanks for catching it.
*** Bug 192579 has been marked as a duplicate of this bug. ***
The bug has long ago been fixed in grep CVS, but for some reason they haven't made any new release since. The patch can be found at http://lists.gnu.org/archive/html/grep-commit/2004-11/msg00095.html.
Fixed in Fedora Core devel.