You are right, after further tests; it looks like a thread scheduling
problem, it could perhaps be solved by making the thread critical, but
then it only return the EAGAIN error. Well, it seems I'm stock here,
better find another way around :-)

thx
Yannick

-----Original Message-----
From: ts [mailto:decoux / moulon.inra.fr] 
Sent: Friday, March 26, 2004 9:58 PM
To: ruby-talk ML
Cc: ruby-talk / ruby-lang.org
Subject: Re: non blocking read and thread

>>>>> "y" == yannick  <yannick / dazzlebox.com> writes:

y> Thanks you for your answer, but that's not really what I meant. I
know
y> than by closing the socket you unblock it anyway, but I would like to
y> know why there is a difference between reading a non blocking IO in
the
y> main thread and reading it in another thread.

 Re-read your script, you have 2 threads : the main thread waiting that
 `thr' finish  and `thr' waiting for reading a character or EOF.

 They are blocked : even if the read is non-blocking, the control is
given
 to the main thread (which wait for the termination of `thr') which give
 the control to `thr' (which try to read a character) which give the
 control to the main thread (which wait for the termination of `thr'),
etc 


Guy Decoux