summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-04 15:35:08 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-04 15:35:08 +0000
commit80a3f22b77d1be4e06e8246d07b0eaeaaf1d8e35 (patch)
tree82d31c71d51cd45062fd6c7ce01d5627d2b92326 /process.c
parent49b10fd508850e396f181101770948aaf8517922 (diff)
* process.c (run_exec_dup2): need to sort by reverted order when
restoring fds. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r--process.c15
1 files changed, 14 insertions, 1 deletions
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++) {