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

ruby-changes:8987

From: usa <ko1@a...>
Date: Fri, 5 Dec 2008 00:36:49 +0900 (JST)
Subject: [ruby-changes:8987] Ruby:r20523 (trunk): * process.c (run_exec_dup2): need to sort by reverted order when

usa	2008-12-05 00:35:08 +0900 (Fri, 05 Dec 2008)

  New Revision: 20523

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

  Log:
    * process.c (run_exec_dup2): need to sort by reverted order when
      restoring fds.

  Modified files:
    trunk/ChangeLog
    trunk/process.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 20522)
+++ ChangeLog	(revision 20523)
@@ -1,3 +1,8 @@
+Fri Dec  5 00:34:10 2008  NAKAMURA Usaku  <usa@r...>
+
+	* process.c (run_exec_dup2): need to sort by reverted order when
+	  restoring fds.
+
 Fri Dec  5 00:17:18 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* string.c (sym_to_proc): caches Symbol procs, based on a patch from
Index: process.c
===================================================================
--- process.c	(revision 20522)
+++ process.c	(revision 20523)
@@ -1767,7 +1767,11 @@
     va_list ap;
     FILE *tty;
     int save = errno;
+#ifdef _WIN32
+    tty = fopen("con", "w");
+#else
     tty = fopen("/dev/tty", "w");
+#endif
     if (!tty)
         return;
 
@@ -1876,6 +1880,12 @@
 }
 
 static int
+intrcmp(const void *a, const void *b)
+{
+    return *(int*)b - *(int*)a;
+}
+
+static int
 run_exec_dup2(VALUE ary, VALUE save)
 {
     int n, i;
@@ -1900,7 +1910,10 @@
     }
 
     /* sort the table by oldfd: O(n log n) */
-    qsort(pairs, n, sizeof(struct fd_pair), intcmp);
+    if (!save)
+        qsort(pairs, n, sizeof(struct fd_pair), intcmp);
+    else
+        qsort(pairs, n, sizeof(struct fd_pair), intrcmp);
 
     /* initialize older_index and num_newer: O(n log n) */
     for (i = 0; i < n; i++) {

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

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