[comp.lang.c] stdio buffering vs. inherited paths

jejones@mcrware.UUCP (James Jones) (07/12/90)

Suppose I am trying to write a flexible archiver of the sort that tries to
compress stored files, and instead of having to stuff in every compression
method known to man, I try the Software Tools approach, and have a program
that writes the surrounding information (file name, date, permissions, etc.)
and spawns a child process to do the actual compression, handing it the
archive file being created as standard output.

Of course, it should flush before doing that...but it's almost certain that
the children, and the parent after the first farming out of a compress, are,
if they are using standard I/O, carefully writing out good-sized (for the
system) hunks of stuff--that isn't aligned on disk sector (or track, for the
ambitious!) boundaries.

The solution, no doubt, is for the parent to write the compressed stuff to the
file itself, reading from a pipe it hooks the compressor's output to.  But it
does make me wonder: does any standard I/O package bothers to notice that a
file it's got open for writing could have been inherited at any old position?
(For that matter, a program even without inherited paths could fseek to any
old position.)

	James Jones