grep hangs on recursive search

· 94 words · 1 minute read

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'