[前][次][番号順一覧][スレッド一覧]

ruby-changes:22403

From: kosaki <ko1@a...>
Date: Tue, 7 Feb 2012 05:36:59 +0900 (JST)
Subject: [ruby-changes:22403] kosaki:r34452 (ruby_1_9_3): merge revision(s) 33567,33573:

kosaki	2012-02-07 05:35:30 +0900 (Tue, 07 Feb 2012)

  New Revision: 34452

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34452

  Log:
    merge revision(s) 33567,33573:
    
    * ruby.c (fill_standard_fds): new function to open closed standard
      file descriptors.
      (ruby_sysinit): call fill_standard_fds.
    
    * ruby.c (fill_standard_fds): use fstat() instead of fcntl(F_GETFD)
      for MinGW.  reported by Luis Lavena.  [ruby-core:40526] [Bug #5516]

  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/ruby.c
    branches/ruby_1_9_3/version.h

Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 34451)
+++ ruby_1_9_3/ChangeLog	(revision 34452)
@@ -1,3 +1,14 @@
+Mon Feb  6 15:34:47 2012  Tanaka Akira  <akr@f...>
+
+	* ruby.c (fill_standard_fds): use fstat() instead of fcntl(F_GETFD)
+	  for MinGW.  reported by Luis Lavena.  [ruby-core:40526] [Bug #5516]
+
+Mon Feb  6 15:34:47 2012  Tanaka Akira  <akr@f...>
+
+	* ruby.c (fill_standard_fds): new function to open closed standard
+	  file descriptors.
+	  (ruby_sysinit): call fill_standard_fds.
+
 Mon Feb  6 15:19:17 2012  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* io.c (rb_io_fsync,rb_io_fdatasync): release GVL during fsync().
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 34451)
+++ ruby_1_9_3/version.h	(revision 34452)
@@ -1,5 +1,5 @@
 #define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 45
+#define RUBY_PATCHLEVEL 46
 
 #define RUBY_RELEASE_DATE "2012-02-07"
 #define RUBY_RELEASE_YEAR 2012
Index: ruby_1_9_3/ruby.c
===================================================================
--- ruby_1_9_3/ruby.c	(revision 34451)
+++ ruby_1_9_3/ruby.c	(revision 34452)
@@ -1815,6 +1815,36 @@
     return (void*)(struct RData*)iseq;
 }
 
+static void
+fill_standard_fds(void)
+{
+    int f0, f1, f2, fds[2];
+    struct stat buf;
+    f0 = fstat(0, &buf) == -1 && errno == EBADF;
+    f1 = fstat(1, &buf) == -1 && errno == EBADF;
+    f2 = fstat(2, &buf) == -1 && errno == EBADF;
+    if (f0) {
+        if (pipe(fds) == 0) {
+            close(fds[1]);
+            if (fds[0] != 0) {
+                dup2(fds[0], 0);
+                close(fds[0]);
+            }
+        }
+    }
+    if (f1 || f2) {
+        if (pipe(fds) == 0) {
+            close(fds[0]);
+            if (f1 && fds[1] != 1)
+                dup2(fds[1], 1);
+            if (f2 && fds[1] != 2)
+                dup2(fds[1], 2);
+            if (fds[1] != 1 && fds[1] != 2)
+                close(fds[1]);
+        }
+    }
+}
+
 void
 ruby_sysinit(int *argc, char ***argv)
 {
@@ -1827,4 +1857,5 @@
 #if defined(USE_DLN_A_OUT)
     dln_argv0 = origarg.argv[0];
 #endif
+    fill_standard_fds();
 }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]