mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
merge revision(s) 33567,33573:
* ruby.c (fill_standard_fds): new function to open closed standard file descriptors. (ruby_sysinit): call fill_standard_fds. * ruby.c (fill_standard_fds): use fstat() instead of fcntl(F_GETFD) for MinGW. reported by Luis Lavena. [ruby-core:40526] [Bug #5516] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ea0ef6af83
commit
04918f8156
3 changed files with 43 additions and 1 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
Mon Feb 6 15:34:47 2012 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ruby.c (fill_standard_fds): use fstat() instead of fcntl(F_GETFD)
|
||||
for MinGW. reported by Luis Lavena. [ruby-core:40526] [Bug #5516]
|
||||
|
||||
Mon Feb 6 15:34:47 2012 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ruby.c (fill_standard_fds): new function to open closed standard
|
||||
file descriptors.
|
||||
(ruby_sysinit): call fill_standard_fds.
|
||||
|
||||
Mon Feb 6 15:19:17 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||
|
||||
* io.c (rb_io_fsync,rb_io_fdatasync): release GVL during fsync().
|
||||
|
|
31
ruby.c
31
ruby.c
|
@ -1815,6 +1815,36 @@ ruby_process_options(int argc, char **argv)
|
|||
return (void*)(struct RData*)iseq;
|
||||
}
|
||||
|
||||
static void
|
||||
fill_standard_fds(void)
|
||||
{
|
||||
int f0, f1, f2, fds[2];
|
||||
struct stat buf;
|
||||
f0 = fstat(0, &buf) == -1 && errno == EBADF;
|
||||
f1 = fstat(1, &buf) == -1 && errno == EBADF;
|
||||
f2 = fstat(2, &buf) == -1 && errno == EBADF;
|
||||
if (f0) {
|
||||
if (pipe(fds) == 0) {
|
||||
close(fds[1]);
|
||||
if (fds[0] != 0) {
|
||||
dup2(fds[0], 0);
|
||||
close(fds[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (f1 || f2) {
|
||||
if (pipe(fds) == 0) {
|
||||
close(fds[0]);
|
||||
if (f1 && fds[1] != 1)
|
||||
dup2(fds[1], 1);
|
||||
if (f2 && fds[1] != 2)
|
||||
dup2(fds[1], 2);
|
||||
if (fds[1] != 1 && fds[1] != 2)
|
||||
close(fds[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ruby_sysinit(int *argc, char ***argv)
|
||||
{
|
||||
|
@ -1827,4 +1857,5 @@ ruby_sysinit(int *argc, char ***argv)
|
|||
#if defined(USE_DLN_A_OUT)
|
||||
dln_argv0 = origarg.argv[0];
|
||||
#endif
|
||||
fill_standard_fds();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#define RUBY_VERSION "1.9.3"
|
||||
#define RUBY_PATCHLEVEL 45
|
||||
#define RUBY_PATCHLEVEL 46
|
||||
|
||||
#define RUBY_RELEASE_DATE "2012-02-07"
|
||||
#define RUBY_RELEASE_YEAR 2012
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue