J
James Kuyper
On 15-Oct-13 13:56, glen herrmannsfeldt wrote: ....
When you redirect with < or >, the OS connects stdin or stdout to the
named file rather than the console; it's still a _file_. Using "cat"
meant that stdin and stdout were connected to a _pipe_ instead, which
gives fseek() and ftell() well-defined behavior that apparently didn't
crash the program.
I had thought that pipes were, in the relevant senses, equivalent to
files. I can't say that I've every knowingly used either '<' or '|' to
send input to a program that would use fseek() on it's input file. In my
experience, programs that do that sort of thing don't do it to either
stdin or stdout - they open the relevant file by name. What precisely is
the relevant difference between those two methods of passing to stdin,
in terms of what's supposed to happen when fseek() is called?
AFAIK, there was no need for programs to be "linked with a special
option" to get access to fseek64()/ftell64(); those should have been
included in the normal 32-bit libc as soon as the OS itself supported
large files. Likewise, the 64-bit libc should have supported large
files from the start, via both interfaces.
fseek64() and ftell64() are not reserved names as far as C is concerned.
Strictly conforming code can use such identifiers for functions with
external linkage, without worrying about conflicting with the POSIX
functions of the same name. Whatever options are needed to make that
possible could not be used when building a program which actually needed
to use the POSIX versions.
There are a few possibilities I can see: ....
3. cat didn't use fseek() or ftell() at all.
I can't come up with any reason why it would need to.