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

  1. Path: sparky!uunet!elroy.jpl.nasa.gov!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: 27 Dec 1992 08:17:32 GMT
  6. Organization: HST Wide Field/Planetary Camera
  7. Lines: 61
  8. Distribution: world
  9. Message-ID: <1hjoqsINN34t@gap.caltech.edu>
  10. References: <24DEC199220084219@spades.aces.com> <Bzt6EF.Est@dale.cts.com>,<1992Dec26.211521.4768@spcvxb.spc.edu>
  11. Reply-To: carl@SOL1.GPS.CALTECH.EDU
  12. NNTP-Posting-Host: sol1.gps.caltech.edu
  13.  
  14. In article <1992Dec26.211521.4768@spcvxb.spc.edu>, terry@spcvxb.spc.edu (Terry
  15. Kennedy, Operations Mgr.) writes:
  16. >In article <Bzt6EF.Est@dale.cts.com>, glippert@dale.cts.com (George Lippert) writes:
  17. >> So how do I make sure that the buffer gets onto disk? (in my case), I asked.
  18. >> They told me that there is an "unsupported and undocumented" function that I
  19. >> could call.  Thanks, but no thanks, I said.
  20. >
  21. >  At the risk of adding some useful information to this discussion 8-), I
  22. >think they were talking about the VAX C fsync() function.
  23.  
  24. Not that I doubt your claim, but under VMS v4.4-2, there's no documentation for
  25. this function.  Now, if you:
  26.     $ ANAL/IMAGE/OUT=TMP.TMP SYS$SHARE:VAXCRTL
  27.     $ SEARCH TMP.TMP "Symbol: ""FSYNC"""
  28. you'll find that there *IS* such a routine.  But that doesn't help a whole lot. 
  29. What argument does FSYNC take?  Is it the file descriptor or the file pointer?
  30. Really, I'd like to know, since it's there but undocumented?  How do I *USE*
  31. it?  (see:  I've clearly stated what I *don't* know, and have asked for
  32. clarification;  I admit that, since we're talking about VAX C, I've assumed the
  33. argument is either a file descriptor or a file pointer;  but if it's neither of
  34. the above, I'd still like to know).
  35.  
  36. >2694 ;++ [095]
  37. >2695 ; fsync - force a synchronization of file with user I/O
  38. >2696 ;
  39. >2697 ;    This function simply calls SYS$FLUSH for the file indicated to
  40. >2698 ;    make sure that the physical I/O happens NOW for any logical I/O
  41. >2699 ;    calls that the user has made.
  42. >2700 ;
  43. >2701 ; input:
  44. >2702 ;    4(ap)    file descriptor number
  45.  
  46. OK. Never mind.  If I want to flush stdout, I should:
  47.     fflush(stdout);
  48.     fsync(fileno(stdout));
  49. Please note:  You need to do both the fflush() AND the fsync()!
  50.  
  51. Why?  Well the fsync flushes the RMS buffers.  But unless you've done the
  52. fflush, the data might not've made it that far!  So you've got to fflush() to
  53. get the data to RMS, then the fsync() to get it to disk.
  54.  
  55. Please note that this particular butthead (me) has taken the time (about 5
  56. minutes) to test the solution given and add a rather critical caveat (i.e.,
  57. that you've got to do an fflush() before the fsync()).  Why?  Because I want to
  58. understand what's going on.  I'd *STILL* rather have the whole thing documented
  59. and supported, though!
  60.  
  61. Now, ask yourself:  Would the dickheads in this group even have wondered about
  62. whether you had to do an fflush() first (this last comment is *NOT* intended as
  63. a dig at Terry Kennedy, who's provided some very useful information; it's
  64. directed at those dickheads who'd try Terry's solution and then say "But it
  65. doesn't work," without bothering to consider that there are two levels of I/O
  66. here).
  67. --------------------------------------------------------------------------------
  68. Carl J Lydick | INTERnet: CARL@SOL1.GPS.CALTECH.EDU | NSI/HEPnet: SOL1::CARL
  69.  
  70. Disclaimer:  Hey, I understand VAXen and VMS.  That's what I get paid for.  My
  71. understanding of astronomy is purely at the amateur level (or below).  So
  72. unless what I'm saying is directly related to VAX/VMS, don't hold me or my
  73. organization responsible for it.  If it IS related to VAX/VMS, you can try to
  74. hold me responsible for it, but my organization had nothing to do with it.
  75.