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'.


 > 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.
 > 
 > One of the reasons for this could be that the file is open while
 > truncate is being called - would this be a problem ?

Yes I think so.  Truncate is implemented in glibc by calling open &
ftruncate.  You then have two file descriptors and depending on which
gets flushed/sync'ed there may be problems.

I would try calling fflush(stream)/ftruncate(fileno(stream)) where
"stream" is the open FILE* on the file in question.



 > --- 2,9 ----
 >   #include "fio.h"
 >   
 > + #ifdef HAVE_TRUNCATE
 > + #include <unistd.h>
 > + #endif /* defined(HAVE_TRUNCATE) */
 > + 

Please don't do this.  Either include unistd.h unconditionally, (gcc
fixproto guarantees that it exists and libf2c is a target lib) or
check/test HAVE_UNISTD_H.

It might also be a good time to remove the KR_headers stuff, since
libf2c is only compiled by gcc now.

		--Kaveh
--
Kaveh R. Ghazi			Engagement Manager / Project Services
ghazi@caip.rutgers.edu		Qwest Internet Solutions


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