[macruby-changes] [4259] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Mon Jun 21 18:15:17 PDT 2010


Revision: 4259
          http://trac.macosforge.org/projects/ruby/changeset/4259
Author:   martinlagardette at apple.com
Date:     2010-06-21 18:15:15 -0700 (Mon, 21 Jun 2010)
Log Message:
-----------
Fix open3 lib + Process.spawn

 - Fixes #590
 - Fixes <rdar://problem/8097009>

Modified Paths:
--------------
    MacRuby/trunk/lib/open3.rb
    MacRuby/trunk/process.c

Modified: MacRuby/trunk/lib/open3.rb
===================================================================
--- MacRuby/trunk/lib/open3.rb	2010-06-22 00:26:46 UTC (rev 4258)
+++ MacRuby/trunk/lib/open3.rb	2010-06-22 01:15:15 UTC (rev 4259)
@@ -203,13 +203,11 @@
     wait_thr = Process.detach(pid)
     child_io.each {|io| io.close }
     result = [*parent_io, wait_thr]
-    if defined? yield
-      begin
-	return yield(*result)
-      ensure
-	parent_io.each{|io| io.close unless io.closed?}
-        wait_thr.join
-      end
+    begin
+      return yield(*result)
+    ensure
+      parent_io.each{|io| io.close unless io.closed?}
+      wait_thr.join if wait_thr
     end
     result
   end

Modified: MacRuby/trunk/process.c
===================================================================
--- MacRuby/trunk/process.c	2010-06-22 00:26:46 UTC (rev 4258)
+++ MacRuby/trunk/process.c	2010-06-22 01:15:15 UTC (rev 4259)
@@ -1247,28 +1247,38 @@
 static VALUE
 check_exec_redirect_fd(VALUE v)
 {
-#if 0 // TODO
     VALUE tmp;
     int fd;
     if (FIXNUM_P(v)) {
         fd = FIX2INT(v);
     }
+    else if (SYMBOL_P(v)) {
+        ID id = SYM2ID(v);
+        if (id == rb_intern("in"))
+            fd = 0;
+        else if (id == rb_intern("out"))
+            fd = 1;
+        else if (id == rb_intern("err"))
+            fd = 2;
+        else
+            goto wrong;
+    }
     else if (!NIL_P(tmp = rb_check_convert_type(v, T_FILE, "IO", "to_io"))) {
-        rb_io_t *fptr;
-        GetOpenFile(tmp, fptr);
+        rb_io_t *fptr = ExtractIOStruct(tmp);
+#if 0
         if (fptr->tied_io_for_writing)
             rb_raise(rb_eArgError, "duplex IO redirection");
+#endif
         fd = fptr->fd;
     }
     else {
         rb_raise(rb_eArgError, "wrong exec redirect");
     }
     if (fd < 0) {
+      wrong:
         rb_raise(rb_eArgError, "negative file descriptor");
     }
     return INT2FIX(fd);
-#endif
-	rb_notimplement();
 }
 
 static void
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100621/a3a08109/attachment-0001.html>


More information about the macruby-changes mailing list