Skip to content

Commit

Permalink
[OHAI-196] work around broken select on older linux kernels
Browse files Browse the repository at this point in the history
linux kernels prior to 2.6.30 block indefinitely when calling IO.select
on sysfs file descriptors. Using read_nonblock works around this bug.
  • Loading branch information
danielsdeleo committed Jun 16, 2010
1 parent 1503b67 commit 518d56a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/ohai/plugins/linux/block_device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
block[dir] = Mash.new
%w{size removable}.each do |check|
if File.exists?("/sys/block/#{dir}/#{check}")
block[dir][check] = File.read("/sys/block/#{dir}/#{check}").chomp
File.open("/sys/block/#{dir}/#{check}") { |f| block[dir][check] = f.read_nonblock(1024).strip }
end
end
%w{model rev state timeout vendor}.each do |check|
if File.exists?("/sys/block/#{dir}/device/#{check}")
block[dir][check] = File.read("/sys/block/#{dir}/device/#{check}").chomp
File.open("/sys/block/#{dir}/device/#{check}") { |f| block[dir][check] = f.read_nonblock(1024).strip }
end
end
end
Expand Down

0 comments on commit 518d56a

Please sign in to comment.