mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* win32/win32.c (init_stdhandle): redirect unopened IOs to NUL.
[ruby-core:09572] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11362 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
24f3250be1
commit
4abaf3a579
2 changed files with 16 additions and 4 deletions
|
@ -1,8 +1,11 @@
|
|||
Wed Dec 6 23:56:14 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
Wed Dec 6 23:58:36 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* Makefile.in, common.mk (NULLCMD): moved for platforms that empty
|
||||
command does not run. fixed: [ruby-dev:29994]
|
||||
|
||||
* win32/win32.c (init_stdhandle): redirect unopened IOs to NUL.
|
||||
[ruby-core:09572]
|
||||
|
||||
Tue Dec 5 19:01:42 2006 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||
|
||||
* configure.in (SITE_DIR): fixed to emtpy RUBY_SITE_LIB in config.h on
|
||||
|
|
|
@ -1731,15 +1731,24 @@ rb_w32_open_osfhandle(long osfhandle, int flags)
|
|||
static void
|
||||
init_stdhandle(void)
|
||||
{
|
||||
int nullfd = -1;
|
||||
int keep = 0;
|
||||
#define open_null(fd) \
|
||||
(((nullfd < 0) ? \
|
||||
(nullfd = open("NUL", O_RDWR|O_BINARY)) : 0), \
|
||||
((nullfd == (fd)) ? (keep = 1) : dup2(nullfd, fd)), \
|
||||
(fd))
|
||||
|
||||
if (fileno(stdin) < 0) {
|
||||
stdin->_file = 0;
|
||||
stdin->_file = open_null(0);
|
||||
}
|
||||
if (fileno(stdout) < 0) {
|
||||
stdout->_file = 1;
|
||||
stdout->_file = open_null(1);
|
||||
}
|
||||
if (fileno(stderr) < 0) {
|
||||
stderr->_file = 2;
|
||||
stderr->_file = open_null(2);
|
||||
}
|
||||
if (nullfd >= 0 && !keep) close(nullfd);
|
||||
}
|
||||
#else
|
||||
|
||||
|
|
Loading…
Reference in a new issue