[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: performance of shell read loops
On Sat, Mar 12, 2016 at 10:17:26PM +0700, Robert Elz wrote:
> | Actually I was wondering if there aren't more use cases for a "read
> | until you find the following sequence" system call or just something
> | specifiying a (simple) regular expression.
> I was too - but I suspect that the only users that matter would want \n
> as the terminator (or EOF of course) - other stuff (vi input mode that
> can end on ESC) don't do enough input for it to be worth the bother. So
> I suspect that just line mode buffering (like ttys do, and like is available
> on output via stdio) would probably be enough for 90% of uses, or more.
> More complexity just makes it harder to use, and more likely to be full of
> bugs. "Line mode input" could be a simple fcntl flag.
I was consider this primarily as complement of getline and getdelim.
As such, at least making the end token configurable seems sensible and
doesn't cost anything. Making it a flag is somewhat problematic as it
would be sticky, which is not necessarily something you want to have.
This is even more true when the file descriptor is potentially shared,
consider all the problem O_NONBLOCK can create for unsuspecting
Main Index |
Thread Index |