Excerpts (reformatted) from Nobuyoshi Nakada's mail of 26 Aug 2004 (EDT):
> Maybe, strace log?

Under Ruby 1.8.2 with kernel 2.6.8.1, with this code:

  PROC_FILE = "/proc/acpi/battery/BAT1/state"
  Thread.new { sleep 1000 }
  puts "=== starting to read at #{Time.now}"
  IO.foreach(PROC_FILE) { }
  puts "===     done reading at #{Time.now}"

I get the following strace output:

  [...]
  write(1, "=== starting to read at Fri Aug "..., 53=== starting to read at Fri Aug 27 10:26:58 EDT 2004
  ) = 53
  sigprocmask(SIG_BLOCK, NULL, [])        = 0
  open("/proc/acpi/battery/BAT1/state", O_RDONLY|O_LARGEFILE) = 3
  sigprocmask(SIG_BLOCK, NULL, [])        = 0
  gettimeofday({1093616818, 153673}, NULL) = 0
  select(4, [3], [], [], {999, 998330}

and it just hangs on that select. If I remove the Thread.new call, I get
this strace output:

  [...]
  open("/proc/acpi/battery/BAT1/state", O_RDONLY|O_LARGEFILE) = 3
  sigprocmask(SIG_BLOCK, NULL, [])        = 0
  fstat64(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
  mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x402b7000
  read(3, "present:                 yes\ncap"..., 1024) = 188
  read(3, "", 1024)                       = 0
  close(3)                                = 0
  munmap(0x402b7000, 4096)                = 0
  gettimeofday({1093616966, 205006}, NULL) = 0
  write(1, "===     done reading at Fri Aug "..., 53===     done reading at Fri Aug 27 10:29:26 EDT 2004
  ) = 53

If I change the filename to /proc/acpi/power_resource/PFAN/state in the
code with threads, select() is used, but it doesn't block.

So it seems like select() on reading particular files in /proc will
block. I guess the question is, is this a kernel bug or a kernel
feature?

-- 
William <wmorgan-ruby-talk / masanjin.net>