home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!news.claremont.edu!nntp-server.caltech.edu!SOL1.GPS.CALTECH.EDU!CARL
- From: carl@SOL1.GPS.CALTECH.EDU (Carl J Lydick)
- Newsgroups: comp.os.vms
- Subject: re: VAX c
- Date: 30 Dec 1992 11:44:52 GMT
- Organization: HST Wide Field/Planetary Camera
- Lines: 41
- Distribution: world
- Message-ID: <1hs23kINNnqs@gap.caltech.edu>
- References: <9212282111.AA11260@uu3.psi.com>
- Reply-To: carl@SOL1.GPS.CALTECH.EDU
- NNTP-Posting-Host: sol1.gps.caltech.edu
-
- In article <9212282111.AA11260@uu3.psi.com>, leichter@lrw.com (Jerry Leichter) writes:
- >
- > Is there a way to get VAX C to flush the VMS file buffers?
- >
- > I've got a program that reads data in for the tta2: port and then
- > writes it to a file. The problem is that the data doesn't get written
- > to the file until the buffer is full, and that may not happen but once
- > every day or two.
- >
- >Try the fsync() function. Usage: fsync(int fd). Returns EBADF if fd is not
- >a valid file descriptor. (Note that you need a file DESCRIPTOR, not a file
- >POINTER (FILE *); use fileno() to get the file descriptor from a file
- >pointer.) When fsync() returns, all pending changes should be on the disk.
- >(In VMS, this really means that an RMS $FLUSH was executed.)
- >
- >Note that if you are accessing a file using the standard I/O package (i.e.,
- >through a file pointer) you must first do an fflush() to get the data out to
- >the "Unix I/O" level.
-
- Under VMS v5.4-2 you have to do this even if you're using the UNIXIO routines.
- Of course, you don't normally then have a file pointer handy. What you have to
- do in that case is:
- int fd;
- FILE *fp, fdopen();
- fp = fdopen(fd, "a");
- fflush(fp);
- fsync(fd);
- or, if you're only going to do this once, I suppose you could:
- int fd;
- FILE *fdopen();
- fflush(fdopen(fd, "a"));
- fsync(fd);
- Gawd, how I *HATE* UNIX!
- --------------------------------------------------------------------------------
- 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.
-