From:	SMTP%"carl@SOL1.GPS.CALTECH.EDU" 10-JUN-1994 09:23:56.27
To:	EVERHART
CC:	
Subj:	Re: PROBLEM: File Size Is Too Small!!!

From: carl@SOL1.GPS.CALTECH.EDU (Carl J Lydick)
X-Newsgroups: comp.os.vms
Subject: Re: PROBLEM: File Size Is Too Small!!!
Date: 9 Jun 1994 21:28:10 GMT
Organization: HST Wide Field/Planetary Camera
Lines: 36
Distribution: world
Message-ID: <2t81ha$rvo@gap.cco.caltech.edu>
Reply-To: carl@SOL1.GPS.CALTECH.EDU
NNTP-Posting-Host: sol1.gps.caltech.edu
To: Info-VAX@CRVAX.SRI.COM
X-Gateway-Source-Info: USENET

In article <2t7k3b$j4g@jac.zko.dec.com>, vandenheuvel@eps.enet.dec.com (Hein RMS van den Heuvel) writes:
=To prevent such problems and/or control the extend of the damage, please
=consider adding a time and/or data_volume based SYS$FLUSH call to the
=application. The RAB needed for this call can be obtained through FOR$RAB().

That works if and only if you're using the Fortran I/O library to write the
file.  If you're using C, then you need to fflush and then fsync the file:

Fortran version:
	INTEGER*4 FOR$RAB, SYS$FLUSH, STATUS
	OPEN(UNIT=1,FILE='TEST.DAT', STATUS='NEW',SHARED)
	WRITE(1, 10)
10	FORMAT(' Testing.')
	CALL SYS$FLUSH(%VAL(FOR$RAB(1)))
	END

C version:
#include stdio
main()
{	FILE *fp;
	int fd;

	fd = creat("test.dat", 0755, "SHR=GET");
	write(fd, "Testing.", 8);
	fp = fdopen(fd, "w");
	fflush(fp);
	fsync(fd);
}
--------------------------------------------------------------------------------
Carl J Lydick | INTERnet: CARL@SOL1.GPS.CALTECH.EDU | NSI/HEPnet: SOL1::CARL

Disclaimer:  Hey, I understand VAXen and VMS.  That's what I get paid for.  My
understanding of astronomy is purely at the amateur level (or below).  So
unless what I'm saying is directly related to VAX/VMS, don't hold me or my
organization responsible for it.  If it IS related to VAX/VMS, you can try to
hold me responsible for it, but my organization had nothing to do with it.

