Messages in this thread | | | Date | Mon, 26 Apr 1999 19:29:04 -0400 (EDT) | From | "Richard B. Johnson" <> | Subject | Re: sed not working on /proc files |
| |
On Mon, 26 Apr 1999, Stefan Monnier wrote: [SNIPPED] > > > > It happens because files in /proc have zero length. These are not > > real files. To use `sed` and utilities that do lseek you can `cat` > > through a pipe as you have done. Sed's first 'lseek()' returns ESPIPE > > which tells it to not do that again -- and everything is fine. > > I didn't know sed did `lseek' since it works on pipes as well. > And actually, looking at an `strace' output, it seems it doesn't > do any lseek: > [SNIPPED strace] > > But maybe the fstat is the culprit. Maybe sed tries to be smart and > doesn't bother opening files of size zero ? >
The sed on my system, which is quite old, not from a standards distribution, does, indeed do lseek to find the file-size. Your version does 'fstat' which will accomplish the same thing. Typically a program that does 'lseek(0, SEEK_CUR)` expects to have the correct return value or errno be set to ESPIPE which lets it know that it's a pipe, socket, or fifo. This lets it work with such.
In any event, the files in /proc can't be read with `less` either for the same reason, also `more` always shows 0%. It's the expected nature,
Cheers, Dick Johnson ***** FILE SYSTEM WAS MODIFIED ***** Penguin : Linux version 2.2.6 on an i686 machine (400.59 BogoMips). Warning : It's hard to remain at the trailing edge of technology.
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |