home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / os / vms / 19999 < prev    next >
Encoding:
Internet Message Format  |  1992-12-29  |  1.3 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!agate!ucbvax!lrw.com!leichter
  2. From: leichter@lrw.com (Jerry Leichter)
  3. Newsgroups: comp.os.vms
  4. Subject: re: VAX c
  5. Message-ID: <9212282111.AA11260@uu3.psi.com>
  6. Date: 28 Dec 92 20:10:48 GMT
  7. Sender: usenet@ucbvax.BERKELEY.EDU
  8. Organization: The Internet
  9. Lines: 23
  10.  
  11.  
  12.     Is there a way to get VAX C to flush the VMS file buffers? 
  13.  
  14.     I've got a program that reads data in for the tta2: port and then
  15.     writes it to a file. The problem is that the data doesn't get written
  16.     to the file until the buffer is full, and that may not happen but once
  17.     every day or two.
  18.  
  19. Try the fsync() function.  Usage:  fsync(int fd).  Returns EBADF if fd is not
  20. a valid file descriptor.  (Note that you need a file DESCRIPTOR, not a file
  21. POINTER (FILE *); use fileno() to get the file descriptor from a file
  22. pointer.)  When fsync() returns, all pending changes should be on the disk.
  23. (In VMS, this really means that an RMS $FLUSH was executed.)
  24.  
  25. Note that if you are accessing a file using the standard I/O package (i.e.,
  26. through a file pointer) you must first do an fflush() to get the data out to
  27. the "Unix I/O" level.
  28.  
  29. I'm not sure if fsync() is documented yet, but it's been in the RTL for quite
  30. some time; it's a BSD innovation that's been picked up by most recent Unix
  31. implementations.
  32.                             -- Jerry
  33.  
  34.