Bug? Serial ports and threads don't mix

I've just tried it on a different machine, running FreeBSD-5.2.1, and it all
appears to work correctly (including a more sophisticated program using
timeouts) - so perhaps this is a Linux-ism. I'd still like to know why it
happens though.

The Linux kernel is whatever is the default in a RH9.0 install.




On Thu, Sep 02, 2004 at 04:41:13PM +0100, Brian Candler wrote:


I have come across a strange problem with using serial ports under Ruby,
which comes to light when you try to use a ruby thread (even if this is the
only thread which is active).

The attached program demonstrates the problem; it sends three bytes down the
serial port, then waits for three bytes to be received and displays them. At
the end, you'll see two very similar ways of starting the object. If you use

    a = SerialTest.new('/dev/ttyS0')

then it works; but if you use

    t = Thread.new do
      b = SerialTest.new('/dev/ttyS0')

then it doesn't, although clearly the two progams should behave identically.

<< snip >>