Backport #2267

IO#sync = true causes offset to not be updated after writing on OS X/FreeBSD

Added by normalperson (Eric Wong) over 2 years ago. Updated about 1 year ago.

[ruby-core:26300]
Status:Closed Start date:10/26/2009
Priority:Normal Due date:
Assignee:wyhaines (Kirk Haines) % Done:

100%

Category:-
Target version:-

Description

#!/usr/bin/env ruby

f = File.open("bar", File::RDWR|File::CREAT, 0600)
f.sync=true
f.read
f.write "Hello"
puts "Should be 5: #{f.pos}"
f.close
`rm bar`

# from http://gist.github.com/216703
# The output under FreeBSD (7.2) and OS X with both
# Ruby 1.8.7 p160 and 1.8.7 p72 is:
#
#   Should be 5: 0
#
# ref: http://thread.gmane.org/gmane.comp.lang.ruby.unicorn.general/100

Associated revisions

Revision 25485
Added by nobu over 2 years ago

* io.c (io_fwrite): adjust stdio file position after direct write on BSDish platforms. [ruby-core:26300]

Revision 28393
Added by wyhaines almost 2 years ago

io.c: Backport #2267 [ruby-core:26300]; Fix problem with IO so that the file position is correct after a direct write on BSDish platforms like OS X. test/ruby/test_io.rb: Added a test for the fix.

History

Updated by nobu (Nobuyoshi Nakada) over 2 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100
This issue was solved with changeset r25485.
Eric, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

Updated by shyouhei (Shyouhei Urabe) over 2 years ago

  • Status changed from Closed to Assigned
  • Assignee set to wyhaines (Kirk Haines)
I don't have neither environment to reproduce so please reject it if not, but it seems to me that this issue affects 1.8.6.

Updated by wyhaines (Kirk Haines) almost 2 years ago

  • Status changed from Assigned to Closed
This issue was solved with changeset r28393.
Eric, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

Also available in: Atom PDF