Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Jan 1995 22:35:17 MST
From:      steve@khoros.unm.edu (Steven Jorgensen)
To:        questions@FreeBSD.org
Subject:   possible fopen/fclose bug?
Message-ID:  <9501260535.AA25049@zen.khoros.unm.edu>

next in thread | raw e-mail | index | archive | help


	While porting the Khoros imake system to freebsd 2.0, I
	noticed that the Makefiles that our version of imake were
	generating had garbage at the end of the file.  Upon further
	investigation, it became appearent that the problem was in
	the fact that imake does some post processing on the Makefile
	by opening the file w+.  This allows it to read the Makefile
	while writing out the modified information to the same file.
	(Seems kind of dangerous to me, but then I didn't write imake :^)

	Anyway, the problem is that it closes the file where it stopped
	reading instead of where it stopped writing, so garbage appears
	at the end.  This is fixed by inserting an explicit ftruncate
	call right before closing the file.

	Since this ftruncate is not necessary on the other architectures
	we support, I was wondering if this is a bug in freebsd's fclose,
	or whether or not it is an undefined action that we've just been
	lucky with before this.. :^)  

							Steve

-- 
-------------------------------------------------------------
Steven Jorgensen        | Khoral Research Inc.
steve@khoros.unm.edu    | 6001 Indian School, Suite 200
(505) 837-6500          | Albuquerque, NM 87110
------------------------+------------------------------------
This Space for Rent.	| URL: http://www.khoros.unm.edu/
-------------------------------------------------------------



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9501260535.AA25049>