This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: The semantics of `truncate'.
- To: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- Subject: Re: The semantics of `truncate'.
- From: Michael Matz <matzmich at cs dot tu-berlin dot de>
- Date: Sun, 25 Feb 2001 19:52:53 +0100 (MET)
- cc: <gcc at gcc dot gnu dot org>
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.