Eric Blake-1 <[EMAIL PROTECTED]> writes: > 2007-08-17 Eric Blake <[EMAIL PROTECTED]> > > Don't consume too much input when stdin is seekable. > * lib/yesno.c (yesno): Flush seekable stdin. > * modules/yesno (Depends-on): Add fflush.
Won't this patch result in lots of unnecessary system calls for a program that reads a lot of 'y's and 'n'n from a file? > The closein module is capable of resolving this problem. > However, rather than fix all of the affected applications > one-by-one (the list includes, but is not limited to, > coreutils' cp, ln, mv, rm, and remove; and findutils' find), > it would be nicer to fix this just once in yesno. (There is no 'remove' command.) I see another problem with the proposed approach, other than the performance issue. If a program like 'mv' has read from standard input, but then the fseeko fails at the end, then 'mv' should report an error to the user. My kneejerk reaction is that a modified 'closein' is a better way to go here. That is, the affected programs (and there are not that many of them) should invoke close_stdin if they have attempted to read anything from stdin and have not read end-of-file.