home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / bsd / 3002 < prev    next >
Encoding:
Internet Message Format  |  1992-07-27  |  1.5 KB

  1. Path: sparky!uunet!gatech!usenet.ins.cwru.edu!agate!dog.ee.lbl.gov!horse.ee.lbl.gov!torek
  2. From: torek@horse.ee.lbl.gov (Chris Torek)
  3. Newsgroups: comp.unix.bsd
  4. Subject: Re: STDIO Mode "a+" screwed up
  5. Date: 28 Jul 1992 00:47:22 GMT
  6. Organization: Lawrence Berkeley Laboratory, Berkeley
  7. Lines: 27
  8. Message-ID: <24972@dog.ee.lbl.gov>
  9. References: <39897@gremlin.nrtc.northrop.com>
  10. Reply-To: torek@horse.ee.lbl.gov (Chris Torek)
  11. NNTP-Posting-Host: 128.3.112.15
  12.  
  13. In article <39897@gremlin.nrtc.northrop.com> dec@lazarus.nrtc.northrop.com
  14. (Dwight E. Cass) writes:
  15. >   I have just spent the weekend trying to find out why rogue crashes
  16. >when it attempts to update its score file and have found the problem:
  17.  
  18. >   In: /usr/src/lib/libc/stdio/flags.c - Mode "a+" translates to an
  19. >       open flag with O_APPEND (in __sflags()).  This means that if
  20. >       you seek the file to the beginning and start writting, all the
  21. >       written will be APPENDED to the end of the file - rather than
  22. >       updating the top of the file as specified by the plus sign.
  23.  
  24. This is not a bug.  ANSI C standard, section 4.9.5.3, pp. 126--127,
  25. l. 39 ff.:
  26.  
  27.     Opening a file with append mode ('a' as the first character in
  28.     the mode argument) causes all subsequent writes to the file to
  29.     be forced to the then-current end-of-file, *regardless of
  30.     intervening calls to the fseek function*.
  31.  
  32. [emphasis mine]
  33.  
  34. >   What's the cure - ouch.
  35.  
  36. Fix rogue.  It should use "w+" mode.
  37. -- 
  38. In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 510 486 5427)
  39. Berkeley, CA        Domain:    torek@ee.lbl.gov
  40.