This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: The semantics of `truncate'.


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]