home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / os / vms / 19949 < prev    next >
Encoding:
Text File  |  1992-12-28  |  3.9 KB  |  93 lines

  1. Path: sparky!uunet!utcsri!torn!spool.mu.edu!darwin.sura.net!gatech!emory!swrinde!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: flushing in VAXC and DECC
  5. Date: 28 Dec 1992 16:12:46 GMT
  6. Organization: HST Wide Field/Planetary Camera
  7. Lines: 79
  8. Distribution: world
  9. Message-ID: <1hn91uINNnna@gap.caltech.edu>
  10. References: <1992Dec26.211521.4768@spcvxb.spc.edu> <6813@npri6.npri.com>,<1992Dec27.055031.24162@eco.twg.com> <1hjtr9INN34t@gap.caltech.edu>,<1992Dec27.200611.24473@nntpd2.cxo.dec.com>
  11. Reply-To: carl@SOL1.GPS.CALTECH.EDU
  12. NNTP-Posting-Host: sol1.gps.caltech.edu
  13.  
  14. In article <1992Dec27.200611.24473@nntpd2.cxo.dec.com>, winalski@adserv.enet.dec.com (Paul S. Winalski) writes:
  15. >The function behaves as documented.  It flushes all of the C RTL's internal
  16. >buffers and it also does an RMS SYS$FLUSH to force the data to be written to
  17. >disk.
  18. >
  19. >You're being caught by the special RMS processing for process-permanent files.
  20.  
  21. Afraid not.  The same thing happens with the program:
  22.     #include stdio
  23.     main()
  24.     {    FILE *fp;
  25.         fp = fopen("TEST.DAT", "w");
  26.         fprintf(fp, "This is a test.\n");
  27.         fsync(fileno(fp));
  28.         sleep(30);
  29.     }
  30.  
  31. fsync() *MUST* be preceded by an fflush() if you want to be sure that all stuff
  32. that's already been written using standard I/O calls is flushed to disk.  And,
  33. byt the way, despite the claim by another person, the program:
  34.  
  35. #include stdio
  36. main()
  37. {    int fd;
  38.     fd = creat("TEST.DAT");
  39.     write(fd, "This is a test.\n", 16);
  40.     fsync(fd);
  41.     sleep(30);
  42. }
  43.  
  44. Also exhibits exactly the same behavior.  Unfortunately, there doesn't appear
  45. to be any documented way to flush the C I/O buffers if you've been using
  46. write() instead of standard I/O.
  47.  
  48. >When you do a SPAWN/NOWAIT/OUT=filespec, SYS$OUTPUT (aka stdout) is opened in
  49. >supervisor mode by DCL as a process-permanent file.  This is done so that each
  50. >program run in the subprocess doesn't create its own version of the output file.
  51. >Many user-mode RMS operations on a process-permanent file end up being no-ops.
  52. >Among these are SYS$OPEN, SYS$CLOSE, and SYS$FLUSH.  So what happens here is
  53. >that the DECC RTL does write its buffers and do a SYS$FLUSH, but RMS ignores
  54. >the SYS$FLUSH because stdout is a process-permanent file.
  55.  
  56. >Note that your second program above (the one with the fflush()) behaves
  57. >identically to the first one--you still don't see "This is a test." until the
  58. >subprocess terminates.  This is because the fsync()'s SYS$FLUSH is still
  59. >being ignored.
  60.  
  61. Have you actually tried this, or are you just making a wild-assed-guess without
  62. actually testing your claim?  The reason I ask is that your claim is dead wrong
  63. under VMS v5.4-2.  Perhaps it's different under a different version of VMS?
  64.  
  65. >If you change the first program to read:
  66. >
  67. >    #include stdio
  68. >    #include signal
  69. >        main()
  70. >        {
  71. >        FILE *x;
  72. >        x = fopen ("x.x", "w");
  73. >        fprintf(x, "This is a test.");
  74. >        fsync(fileno(x));
  75. >        sleep(30);
  76. >        }
  77. >
  78. >and then run it using the command SPAWN/NOWAIT/OUT=Y.Y RUN program
  79. >you will find that the fsync() flushes "This is a test." to file X.X as the
  80. >fsync() documentation would lead one to believe.
  81.  
  82. Again, is this just a wild-assed guess?  I tried that under VMS v5.4-2, and
  83. once again, your claim is dead wrong.  If it's not simply a guess, what version
  84. of VMS are you running?
  85. --------------------------------------------------------------------------------
  86. Carl J Lydick | INTERnet: CARL@SOL1.GPS.CALTECH.EDU | NSI/HEPnet: SOL1::CARL
  87.  
  88. Disclaimer:  Hey, I understand VAXen and VMS.  That's what I get paid for.  My
  89. understanding of astronomy is purely at the amateur level (or below).  So
  90. unless what I'm saying is directly related to VAX/VMS, don't hold me or my
  91. organization responsible for it.  If it IS related to VAX/VMS, you can try to
  92. hold me responsible for it, but my organization had nothing to do with it.
  93.