[MacRuby-devel] Low-ish level MacRuby interaction

Jude Sutton jude.sutton at gmail.com
Wed Jun 10 23:54:25 PDT 2009


Hi Scott,
Have you considered setting sync to true in your ruby code:

STDOUT.sync = true

This will tell stdout to flush after every write/puts etc.


- Jude


2009/6/11 Scott Thompson <easco at mac.com>

>
> On Jun 10, 2009, at 6:01 PM, Laurent Sansonetti wrote:
>
>  Hi Scott!
>>
>> Here is a code snippet that hijacks stdout using an NSPipe. The idea is to
>> first initialize the MacRuby VM (so that the standard descriptor objects are
>> created), then use dup2(2), then evaluate your Ruby expressions.
>>
>>  <Code snipped for brevity>
>
> I appreciate you taking the time to type that in.  This is basically the
> solution that I came up with.  The problem with this solution (if I'm
> understanding what is going on correctly) is that the output that goes
> through the pipe is buffered while the output that usually goes to the
> controlling terminal is not.
>
> The result is that if the ruby script does not produce "enough" output, the
> reading end of the pipe never sees it.  If the ruby code actually flushes
> the stream (or someone closes the pipe, which I gather also ends the stream)
> then the output makes it all the way, but if both my application and code on
> the Ruby side keep the pipe alive, it's possible for the ruby side to leave
> things in the pipe.
>
> Is it possible to create or set up the ends of the pipe to be un-buffered?
>
>
> Scott
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20090611/7f40976f/attachment.html>


More information about the MacRuby-devel mailing list