From: "Ara.T.Howard" Date: 2004-03-26T07:34:28+09:00 Subject: Re: thread/fork/tk nightmares On Fri, 26 Mar 2004, Tanaka Akira wrote: > In article , > "Ara.T.Howard" writes: > > > program.each{|stmt| i.puts stmt} > > i.flush > > On Linux, the script blocks at puts. > > Try puts in a thread as: > > Thread.new { > program.each{|stmt| i.puts stmt} > i.flush > } i keen observation - with that change the script runs fine even using open3. the question is: why does #puts cause the process to block in a thread which has forked (open3) vs one that has not (spawn)?? > Note that your test script works well on Solaris unlike Linux. ;-) i'm not suprised... > It seems that select(2) behaves differently on Linux and Solaris. (Since > your script uses thread, ruby calls select before a IO operation > implicitly.) > > On Linux, select waits something - read operation on the other end of the pipe? > yes - it does seem so. i have not looked into this however... perhaps i should check on comp.unix.programmer... -a -- =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328 | URL :: http://www.ngdc.noaa.gov/stp/ | TRY :: for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done ===============================================================================