The semantics of `truncate'.

Michael Matz matzmich@cs.tu-berlin.de
Sun Feb 25 10:53:00 GMT 2001


Hi,

On Sun, 25 Feb 2001, Toon Moene wrote:
> The point of this mail is that I can't get it to work if I implement
> ENDFILE using truncate [ the present implementation copies the file to
> be ENDFILE'd to a /tmp file and back, which upset the GAMESS users ]
>
> Somehow, truncate does work in that if I cat the temporary file created
> by io1.f just before the two reads, it indeed only contains one line -
> however, the test still fails because the second read succeeds in spite
> of the END= line.

Possible, because truncate (working on a filename) can truncate the
on-disc file, but might not update all filedescriptor information
assiciated with the same file.  You probably want ftruncate(), which works
on a fd open for writing, which obviously is the case for you anyway.
(Also ftruncate() is more POSIX than truncate())


Ciao,
Michael.



More information about the Gcc mailing list