Hi!

MacRuby makes intensive use of many system Frameworks and libraries, which 
makes us limited by the CAVEATS of fork(). What it means for us, is that we can 
use fork() for the typical pipe+dup2+fork+exec (any exec from the exec family) 
to run a binary and read its output. That's what we use for #` (well we 
actually use posix_spawn, but it is equivalent). But callin the exec() family 
is pretty much all we can safely do within a forked program. Because of the 
said caveats, we cannot do any kind of ruby execution, not even "just" calling 
#exec, since it would use the MacRuby dispatcher, the Obj-C runtime etc.
This makes it impossible for us to implement the "|-" argument to #read / 
#open, or the #fork method.

The main problem is that CoreFoundation would be involved within the two 
processes and share, for example, the same garbage collector.
What is not safe is using anything related to CoreFoundation within the new 
forked process (we could say it's not "fork-safe"), and the dispatcher as well 
as the MacRuby runtime make extensive use of Foundation / CF.
Even if the only operation within the child would be simply calling #exec 
(which we cannot make sure of anyway), calling this method would go through the 
runtime and the dispatcher, unfortunately unsafe.

I hope this explains it :-)
-- 
Thibault Martin-Lagardette



On Jun 4, 2010, at 14:50, [email protected] wrote:

> Just curious: why was MacRuby added to the not-support list for fork() :
> 
> Changeset 3398: mark Process.fork as not supported-implemented.
> 
> Is there some subtle issue that will keep this from being implemented?
> 
> -Daniel
> _______________________________________________
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

_______________________________________________
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

Reply via email to