зеркало из https://github.com/github/ruby.git
* 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
This commit is contained in:
Родитель
49b10fd508
Коммит
80a3f22b77
|
@ -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
|
||||
|
|
15
process.c
15
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;
|
||||
|
||||
|
@ -1875,6 +1879,12 @@ intcmp(const void *a, const void *b)
|
|||
return *(int*)a - *(int*)b;
|
||||
}
|
||||
|
||||
static int
|
||||
intrcmp(const void *a, const void *b)
|
||||
{
|
||||
return *(int*)b - *(int*)a;
|
||||
}
|
||||
|
||||
static int
|
||||
run_exec_dup2(VALUE ary, VALUE save)
|
||||
{
|
||||
|
@ -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++) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче