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

Re: where does 'cat' get it's info?



* John Hasler (john@dhh.gt.org) [010810 08:00]:
> David Roundy writes:
> > I just checked, and ls reports that the file is empty (no great
> > surprise).  So presumably the latter editors first check the size before
> > reading the file, while the former ones simply read from it until they
> > hit EOF.
> 
> Yes, that makes sense.  A very minor kernel bug.

I don't know that it's fair to call this a bug. Consider the
alternative: each time a directory in /proc is accessed the kernel
creates all the output necessary for each "file" therein to determine
the length, just to be able to fill in correct values for ls? Even
still, it would be broken, as stuff in /proc can change instantly, so
the lengths returned would only be ephemerally correct anyway.

It's better this way. It hardly makes sense to try to $EDITOR these
"files" anyway; just use echo and cat. (You're usually just reading or
writing one byte anyway).

-- 
Vineet                                   http://www.anti-dmca.org
Unauthorized use of this .sig may constitute violation of US law.
Qba\'g gernq ba zr\!                  |tr 'a-zA-Z' 'n-za-mN-ZA-M'

Attachment: pgp6cKz4y1JMM.pgp
Description: PGP signature


Reply to: