[MacRuby-devel] Low-ish level MacRuby interaction
Scott Thompson
easco at mac.com
Wed Jun 10 17:04:42 PDT 2009
Howdy folks,
I'm working with MacRuby as it evolves and I've been enjoying it quite
a lot. I'm trying to make use of the system in an unusual way and not
having much luck. I thought I would post here and see if anyone has
suggestions.
What I'm trying to do is use MacRuby as an embedded scripting
language. Using the framework and the Objective-C interface this is
REALLY straightforward and easy.
What I'd like to do, however, is divorce the MacRuby standard streams
(stdout, stdio, stderr) so that I can control them myself. I was able
to do this in a rather straightforward fashion from the Ruby side by,
for example, reopening STDOUT on the write end of an NSPipe that I
create myself.
The issue I've run into is that the NSPipe doesn't appear to grab the
output from Ruby in the same way that original STDOUT does. I've been
reading a lot and I gather that the difference may have something to
do with having STDOUT attached to a "controlling terminal" vs. going
to the pipe.
I've been swimming around in a world of pseudo terminals and pipes and
lots of UNIX-ish stuff that, while it is teaching me a lot, is not
getting me much closer to my goal.
So, my question is can anyone suggest the "best" way I might be able
to hijack the standard streams that are being used by the Ruby runtime
so that I can forward ruby output to my own code?
Scott
More information about the MacRuby-devel
mailing list