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

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

On Thu, Aug 09, 2001 at 08:50:22PM -0500, Lance Peterson wrote:
| I know this is lame, but I don't understand it.
| If I change to the /proc/sys/net/ipv4 directory and emacs ip_forward,
| I see an empty file.  BUT, if I cat /proc/sys/net/ipv4/ip_forward then
| I get a 1 returned.  So where is the info coming from since I don't see
| it in the file when opened with an editor?

/proc is a special filesystem.  The thing is it doesn't exist.  It is
a figment of your imagination.  Seriously, though, it is dynamically
created by the kernel as it is accessed.  Maybe emacs is trying to do
something "weird" with the file when it opens it and it isn't working
right.  cat just uses fopen() then reads the data a little at a time
and spits it back out on STDOUT.  When the file is opened/read the
kernel figures out what data it should have and returns that to the
read calls.

I just checked it on my system using both cat and vim and they give
the identical contents of '1' as well.  Must be emacs isn't right ;-).


Reply to: