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:
classes/cs223-0% strace sed 's/a/a/' /proc/meminfo
execve("/bin/sed", ["sed", "s/a/a/", "/proc/meminfo"], [/* 40 vars */]) = 0
brk(0) = 0x8054060
open("/etc/ld.so.preload", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat(3, {st_mode=0, st_size=0, ...}) = 0
mmap(0, 17344, PROT_READ, MAP_PRIVATE, 3, 0) = 0x4000b000
close(3) = 0
open("/lib/libc.so.6", O_RDONLY) = 3
mmap(0, 4096, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40010000
munmap(0x40010000, 4096) = 0
mmap(0, 672712, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x40010000
mprotect(0x400a1000, 78792, PROT_NONE) = 0
mmap(0x400a1000, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x90000) = 0x400a1000
mmap(0x400a9000, 46024, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x400a9000
close(3) = 0
munmap(0x4000b000, 17344) = 0
personality(PER_LINUX) = 0
getpid() = 22745
brk(0) = 0x8054060
brk(0x8054090) = 0x8054090
brk(0x8055000) = 0x8055000
brk(0x8058000) = 0x8058000
open("/proc/meminfo", O_RDONLY) = 3
fstat(3, {st_mode=0, st_size=0, ...}) = 0
mmap(0, 0, PROT_READ, MAP_PRIVATE, 3, 0) = 0
close(3) = 0
close(1) = 0
_exit(0) = ?
classes/cs223-0%
But maybe the fstat is the culprit. Maybe sed tries to be smart and
doesn't bother opening files of size zero ?
Stefan
PS: I just realized my last posting was duplicated several times because
of a unforgivable bug in a script of mine. I apologize for it.
-
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/