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

  1. Path: sparky!uunet!news.claremont.edu!nntp-server.caltech.edu!SOL1.GPS.CALTECH.EDU!CARL
  2. From: carl@SOL1.GPS.CALTECH.EDU (Carl J Lydick)
  3. Newsgroups: comp.os.vms
  4. Subject: re: VAX c
  5. Date: 30 Dec 1992 11:44:52 GMT
  6. Organization: HST Wide Field/Planetary Camera
  7. Lines: 41
  8. Distribution: world
  9. Message-ID: <1hs23kINNnqs@gap.caltech.edu>
  10. References: <9212282111.AA11260@uu3.psi.com>
  11. Reply-To: carl@SOL1.GPS.CALTECH.EDU
  12. NNTP-Posting-Host: sol1.gps.caltech.edu
  13.  
  14. In article <9212282111.AA11260@uu3.psi.com>, leichter@lrw.com (Jerry Leichter) writes:
  15. >
  16. >    Is there a way to get VAX C to flush the VMS file buffers? 
  17. >
  18. >    I've got a program that reads data in for the tta2: port and then
  19. >    writes it to a file. The problem is that the data doesn't get written
  20. >    to the file until the buffer is full, and that may not happen but once
  21. >    every day or two.
  22. >
  23. >Try the fsync() function.  Usage:  fsync(int fd).  Returns EBADF if fd is not
  24. >a valid file descriptor.  (Note that you need a file DESCRIPTOR, not a file
  25. >POINTER (FILE *); use fileno() to get the file descriptor from a file
  26. >pointer.)  When fsync() returns, all pending changes should be on the disk.
  27. >(In VMS, this really means that an RMS $FLUSH was executed.)
  28. >
  29. >Note that if you are accessing a file using the standard I/O package (i.e.,
  30. >through a file pointer) you must first do an fflush() to get the data out to
  31. >the "Unix I/O" level.
  32.  
  33. Under VMS v5.4-2 you have to do this even if you're using the UNIXIO routines.
  34. Of course, you don't normally then have a file pointer handy.  What you have to
  35. do in that case is:
  36.     int fd;
  37.     FILE *fp, fdopen();
  38.     fp = fdopen(fd, "a");
  39.     fflush(fp);
  40.     fsync(fd);
  41. or, if you're only going to do this once, I suppose you could:
  42.     int fd;
  43.     FILE *fdopen();
  44.     fflush(fdopen(fd, "a"));
  45.     fsync(fd);
  46. Gawd, how I *HATE* UNIX!
  47. --------------------------------------------------------------------------------
  48. Carl J Lydick | INTERnet: CARL@SOL1.GPS.CALTECH.EDU | NSI/HEPnet: SOL1::CARL
  49.  
  50. Disclaimer:  Hey, I understand VAXen and VMS.  That's what I get paid for.  My
  51. understanding of astronomy is purely at the amateur level (or below).  So
  52. unless what I'm saying is directly related to VAX/VMS, don't hold me or my
  53. organization responsible for it.  If it IS related to VAX/VMS, you can try to
  54. hold me responsible for it, but my organization had nothing to do with it.
  55.