On October 21, 2011 11:43, in alt.os.linux,
un...@physics.ubc.ca wrote:
> On 2011-10-21, Aragorn <str...@telenet.be.invalid> wrote:
>> On Friday 21 October 2011 07:45, unruh conveyed the following to
>> alt.os.linux...
>>
>>> On 2011-10-21, Aragorn <str...@telenet.be.invalid> wrote:
>>>> On Thursday 20 October 2011 23:01, unruh conveyed the following to
>>>> alt.os.linux...
>>>>
>>>>> I was using grep -r "name$a.b" /var/spool/postfix
>>>>> to see if there were any files being spooled to that user. But the
>>>>> command never completed, and seemed to be hung on the pipe
>>>>> public/pickup (Ie the prompt never reappeared). ^C got me out of
>>>>> this but why is it hanging? Should not grep be wary of pipes?
[snip]
> It seems it never gets any end of file from the read of the pipe so
> keeps trying to read more. The suggestion to use the -D option works,
> but it really should be the default.
>
That's the nature of named pipes. If there is no writer attached to the pipe
when the reader opens it, the reader suspends immediately. The
reader "wakes up" on the first data written by the writer (which can open
the pipe for writing /after/ the reader opens it for reading), and receives
EOF when the writer closes the pipe.
So, your grep opened the pipe for reading, and found that no writer was
attached to the pipe. This caused the kernel to suspend grep on a pipe
read.
What you need is some process to open the pipe for writing, write to the
pipe, and then /close/ the pipe. The write will "wake up" grep, and the
close will let grep read EOF.
--
Lew Pitcher
Master Codewright & JOAT-in-training | Registered Linux User #112576
Me:
http://pitcher.digitalfreehold.ca/ | Just Linux:
http://justlinux.ca/
---------- Slackware - Because I know what I'm doing. ------