From: Francis Cianfrocca [mailto:garb...@gmail.com]
Sent: Wednesday, June 21, 2006 12:26 AM
The problem isn't that rd.gets waits forever - i didn't described my
problem well enough obviously. The problem is: i get 4 foo!s not one
more. Not only the main thread blocks at the gets but all other ruby
threads do also block. This defeats the whole purpose of
using a pipe
in the first place.
Yes, this does fail on Windows as written (works fine on
Unix), but it has
nothing to do with threads. Take out the thread altogether
and it will still
block forever.
Well.. ??? yes of course, if you block the one and only thread
on an IO operation that never returns your program will block
forever. This should be true for linux also, right?
So the problem is that all threads block because of this IO
operation, how could that be unrelated to threads?
Try writing an extension in C and create your descriptors in
native Win32
code. Those will definitely work with Ruby on both Windows
and Unix (I've
done it). You may have to create two pairs because they will
be half-duplex
on Windows.
native Win32 means calling 'CreatePipe' instead of '_pipe' ?
do you have code for a platform independent implementation?
(using #ifdef)
for the record: ruby 1.9.0 (2006-04-15) [i386-mswin32] seems
to have a fix for that problem.
cheers
Simon