grep hangs on recursive search

Today we had the problem, that a recursive grep was hanging without any output. First approach was to look at what grep was doing:

ps -ef | grep grep
strace -p GREP_PID

Grep tried to read a file supervise uses:

# strace -p 4522
Process 4522 attached - interrupt to quit
open("clamd/supervise/ok", O_RDONLY)    = ? ERESTARTSYS (To be restarted)

After a quick Google search StackOverflow brought the solution – add -D skip to the grep command to skip sockets and FIFO files.
I’ve added the following line to my .bash[rc|_profile]:

alias grep='grep -D skip'

Leave a Reply

Your email address will not be published. Required fields are marked *