Re: sed not working on /proc files

Riley Williams (androsyn@i95.com)
Tue, 27 Apr 1999 09:55:52 -0400 (EDT)


I think the problem is the fact that sed is trying to mmap
the file.

This is from the strace before sed bombs out....

fstat(0, {st_mode=0, st_size=0, ...}) = 0
mmap(0, 0, PROT_READ, MAP_PRIVATE, 0, 0) = 0

I am assuming that this is the expected behavior for such files.
If you want to run sed on proc files just do
cat /proc/modules | sed

This will cause your shell to create a pipe using the pipe() system call
and dup2() this pipe to standard in where sed can then do it mmap() stuff.

BTW I'm not sure if sed is using mmap() directly or if it is coming from
the C library. I'd have to look at the source first. (Which is hard to
get on the subway ;) )

Aaron

On Mon, 26 Apr 1999, Stefan Monnier wrote:

> How do you explain the following problem (with 2.2.6):
>
> # (sed 's/a/a/') </proc/modules
> # (cat | sed 's/a/a/') </proc/modules
> nfsd 147288 1 (autoclean)
> nfs 27856 2 (autoclean)
> lockd 29000 1 (autoclean) [nfsd nfs]
> sunrpc 48492 1 (autoclean) [nfsd nfs lockd]
> autofs 8872 1 (autoclean)
> 3c59x 17456 1 (autoclean)
> opl3 10264 0
> cs4232 2264 0
> ad1848 15152 0 [cs4232]
> uart401 5628 0 [cs4232]
> sound 55080 0 [opl3 cs4232 ad1848 uart401]
> soundcore 2208 6 [sound]
> binfmt_misc 3108 0
> st 23352 0
> softdog 948 1
> unix 10056 72 (autoclean)
> #
>
> It also happens on other /proc files (meminfo, tcp_syncookies, ...).
>
>
> Stefan
>
>
> -
> 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/
>

-
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/