From: Chris Gehlker Date: 2002-02-22T11:50:30+09:00 Subject: Re: Now I'm really confused! On 2/21/02 2:41 PM, "Paul Brannan" wrote: > On Fri, Feb 22, 2002 at 05:52:23AM +0900, Chris Gehlker wrote: >> Here I go answering my own question. I'm doing this for the sake of the >> archive. It turns out that there are two solutions, at least. >> >> The easy one is to prepend >> $stdout.sync= true >> To the program in the IDE's source window. >> >> The hard way is to use setvbuf() from C. I say that its the hard way because >> it would require me to drop out of the high level cocoa API and write a lot >> of RubyStudio in straight C. >> >> There may be another way using BSD file descriptors. I'm going to go look >> that up. > > I've struggled with a similar problem myself [ruby-talk:32646]. In C, > stdout is fully buffered iff it does not point to an interactive device > (otherwise it is line buffered or not buffered at all, though most > platforms make it line buffered). I've been programming Macs so long that I had this model in my head that what you do with a character stream is connect it to a text view. I had no idea that stdio behaved differently when connected to a terminal than when connected to a pipe or a file. Seems like black magic. > Ruby does not appear to call setvbuf() on stdout, stderr, or stdin > (though it does for most other IO objects). Do you think perhaps that > it should? I suspect it's doing the right thing for most uses. Terminal users will get line buffering and most people connecting pipes will want full buffering. My use is probably unusual but sending sync= true seems to fix it. -- Heaven is under our feet as well as over our heads. -Henry David Thoreau, naturalist and author (1817-1862)