зеркало из https://github.com/github/ruby.git
* include/ruby/intern.h (rb_cloexec_dup2): declared.
* io.c (rb_cloexec_dup2): new function. (io_reopen): use rb_cloexec_dup2. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
195fbd18d6
Коммит
0a9cb21e62
|
@ -1,3 +1,10 @@
|
|||
Sat Oct 29 22:06:37 2011 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* include/ruby/intern.h (rb_cloexec_dup2): declared.
|
||||
|
||||
* io.c (rb_cloexec_dup2): new function.
|
||||
(io_reopen): use rb_cloexec_dup2.
|
||||
|
||||
Sat Oct 20 21:08:18 2011 Tajima Akil <artonx@yahoo.co.jp>
|
||||
|
||||
* win32/Makefile.sub (CONFIG_H): have stdint.h if VC2010.
|
||||
|
|
|
@ -504,6 +504,7 @@ int rb_pipe(int *pipes);
|
|||
int rb_reserved_fd_p(int fd);
|
||||
int rb_cloexec_open(const char *pathname, int flags, mode_t mode);
|
||||
int rb_cloexec_dup(int oldfd);
|
||||
int rb_cloexec_dup2(int oldfd, int newfd);
|
||||
#define RB_RESERVED_FD_P(fd) rb_reserved_fd_p(fd)
|
||||
void rb_update_max_fd(int fd);
|
||||
void rb_fd_set_cloexec(int fd);
|
||||
|
|
19
io.c
19
io.c
|
@ -227,6 +227,17 @@ rb_cloexec_dup(int oldfd)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
rb_cloexec_dup2(int oldfd, int newfd)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = dup2(oldfd, newfd);
|
||||
if (ret == -1) return -1;
|
||||
fd_set_cloexec(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define argf_of(obj) (*(struct argf *)DATA_PTR(obj))
|
||||
#define ARGF argf_of(argf)
|
||||
|
||||
|
@ -5870,17 +5881,17 @@ io_reopen(VALUE io, VALUE nfile)
|
|||
if (fd != fd2) {
|
||||
if (IS_PREP_STDIO(fptr) || fd <= 2 || !fptr->stdio_file) {
|
||||
/* need to keep FILE objects of stdin, stdout and stderr */
|
||||
if (dup2(fd2, fd) < 0)
|
||||
if (rb_cloexec_dup2(fd2, fd) < 0)
|
||||
rb_sys_fail_path(orig->pathv);
|
||||
rb_fd_set_cloexec(fd);
|
||||
rb_update_max_fd(fd);
|
||||
}
|
||||
else {
|
||||
fclose(fptr->stdio_file);
|
||||
fptr->stdio_file = 0;
|
||||
fptr->fd = -1;
|
||||
if (dup2(fd2, fd) < 0)
|
||||
if (rb_cloexec_dup2(fd2, fd) < 0)
|
||||
rb_sys_fail_path(orig->pathv);
|
||||
rb_fd_set_cloexec(fd);
|
||||
rb_update_max_fd(fd);
|
||||
fptr->fd = fd;
|
||||
}
|
||||
rb_thread_fd_close(fd);
|
||||
|
|
Загрузка…
Ссылка в новой задаче