From: William Morgan Date: 2004-08-18T21:23:55+09:00 Subject: ruby + linux /proc/acpi deadlock? Hi Rubyists, I'm working on a predictive battery monitor in Ruby. One issue I've found is that when I read /proc/acpi/battery/BAT1/state and there are other Ruby threads running, the read seems to freeze. This doesn't happen with other files in /proc/acpi (that I've tried, at least) and doesn't happen if there's no threading going on. Here's some code that hangs on the read for me: PROC_FILE = "/proc/acpi/battery/BAT1/state" # freezes #PROC_FILE = "/proc/acpi/power_resource/PFAN/state" # doesn't freeze FREEZE = true # when this is true, the "read" thread freezes for me def read puts "=== starting to read at #{Time.now}" IO.foreach(PROC_FILE) { |l| puts "> #{l}" } puts "=== done reading at #{Time.now}" end Thread.new do while true puts "zzz..." sleep 1 end end if FREEZE while true read sleep 1 end This might be some weird kernel interaction thing that's specific to my buggy BIOS, but I thought I'd check and see if others experienced the same behavior. Thanks, -- William