diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-04 15:35:08 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-04 15:35:08 +0000 |
commit | fb3610b783474df6da44c9e9a9ec8148fa3b26c1 (patch) | |
tree | 82d31c71d51cd45062fd6c7ce01d5627d2b92326 /process.c | |
parent | 025c4df3a2a6c89d61417c5e628c5804c1af37dc (diff) | |
download | ruby-fb3610b783474df6da44c9e9a9ec8148fa3b26c1.tar.gz ruby-fb3610b783474df6da44c9e9a9ec8148fa3b26c1.tar.xz ruby-fb3610b783474df6da44c9e9a9ec8148fa3b26c1.zip |
* process.c (run_exec_dup2): need to sort by reverted order when
restoring fds.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@20523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r-- | process.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -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++) { |