Can someone explain why the following code does not work?
Ruby version: ruby 1.6.7 (2002-03-19) [i386-linux]
on Debian

Version A:
----
file = File.new "/dev/video0"
foo = Thread.new {
  file.sysread(3 * 512 * 242)  # 512x242 pixel image, 3 bytes per pixel
  print "done\n"
}

foo.join
----

Version B:
----
Thread.new {
  while true
    sleep 1
  end
}

file = File.new "/dev/video0"
file.sysread(3 * 512 * 242)  # 512x242 pixel image, 3 bytes per pixel
print "done\n"
----

I'm trying to read data from the video device from a thread.  The code
works when written without threads.  However, neither version A nor B
works as written above.  Both hang in the .sysread.

/dev/video0 is a video4linux device (webcam), but the particular driver
(3comhc, http://homeconnectusb.sf.net) does not require any ioctl setup;
a simple "cat /dev/video0 > foo.raw" produces an image.  Replacing
"/dev/video0" with "/dev/zero" causes both scripts to work.  And using
"read" instead of "sysread" still fails.

Thanks.

-- 
Pat Mahoney	<pat / tinyleaf.org>