bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug #17457] "grep -r foo . > somefile" goes into an infinite loop


From: Tony Abou-Assaleh
Subject: Re: [bug #17457] "grep -r foo . > somefile" goes into an infinite loop
Date: Sun, 07 Feb 2010 14:30:18 -0400
User-agent: Thunderbird 2.0.0.21 (Macintosh/20090302)

Paolo Bonzini wrote:
> 
>> Actually, how about detecting this and diagnosing
>> the problem rather than falling into the infloop?
>>
>> This currently evokes an infloop for me:
>>
>>      $ seq 1000000>  k
>>      $ grep 111 k>>  k
>>
>> However, simply detecting when the output FD is also an input FD is
>> not enough, since this variant does not get stuck:
>>
>>      $ seq 1000>  k
>>      $ grep 111 k>>  k
> 
> Whether it gets stuck is mainly a function of the buffer size for the
> file.  Certainly whatever is added at the end of "k" matches, so it will
> be added over and over.
> 
> This is a problem for every Unix utility that reads files sequentially
> (e.g. sed or, from coreutils, cut, cat, fmt, tail, comm).

Regardless of what the root cause of the problem is, clearly the
behaviour does not match the user's expectations under normal usage.

But based on Paolo's remarks I wonder whether the problem lies deeper
within how GNU/Linux handles files, and whether grep is a suitable place
for addressing it at this time.

Having said that, if there is a "workaround" to address this behaviour
in grep, then I am in favour of including it.

I'd say this issue is of low priority, but should keep it open for when
someone manages to address it.

Cheers,

TAA

-- 
Tony Abou-Assaleh, PhD
Email:    address@hidden
Web site: http://tony.abou-assaleh.net
LinkedIn: http://www.linkedin.com/in/tabouasssaleh
Twitter:  http://twitter.com/tony_aa




reply via email to

[Prev in Thread] Current Thread [Next in Thread]