aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--process.c15
2 files changed, 19 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 6c8eaf3928..60deb3a729 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Dec 5 00:34:10 2008 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * process.c (run_exec_dup2): need to sort by reverted order when
+ restoring fds.
+
Fri Dec 5 00:17:18 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (sym_to_proc): caches Symbol procs, based on a patch from
diff --git a/process.c b/process.c
index 713ab15976..2342c4b832 100644
--- a/process.c
+++ b/process.c
@@ -1767,7 +1767,11 @@ ttyprintf(const char *fmt, ...)
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 @@ intcmp(const void *a, const void *b)
}
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 @@ run_exec_dup2(VALUE ary, VALUE save)
}
/* 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++) {