зеркало из https://github.com/github/ruby.git
* eval.c (rb_thread_fd_close): raise for writing threads.
[ruby-dev:20269] * io.c (rb_io_close, io_reopen): ditto. * io.c (io_reopen): keep stdio objects for stdin, stdout, and stderr. [ruby-dev:19442] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
1359207bf8
Коммит
874eca3c04
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
Thu May 22 02:42:49 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||
|
||||
* eval.c (rb_thread_fd_close): raise for writing threads.
|
||||
[ruby-dev:20269]
|
||||
|
||||
* io.c (rb_io_close, io_reopen): ditto.
|
||||
|
||||
* io.c (io_reopen): keep stdio objects for stdin, stdout,
|
||||
and stderr. [ruby-dev:19442]
|
||||
|
||||
Thu May 22 01:11:15 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||
|
||||
* parse.y (strings, word_list): must create new instance always.
|
||||
|
|
6
eval.c
6
eval.c
|
@ -8170,7 +8170,11 @@ rb_thread_fd_close(fd)
|
|||
rb_thread_t th;
|
||||
|
||||
FOREACH_THREAD(th) {
|
||||
if ((th->wait_for & WAIT_FD) && fd == th->fd) {
|
||||
if (((th->wait_for & WAIT_FD) && fd == th->fd) ||
|
||||
((th->wait_for & WAIT_SELECT) && (fd < th->fd) &&
|
||||
(FD_ISSET(fd, &th->readfds) ||
|
||||
FD_ISSET(fd, &th->writefds) ||
|
||||
FD_ISSET(fd, &th->exceptfds)))) {
|
||||
VALUE exc = rb_exc_new2(rb_eIOError, "stream closed");
|
||||
rb_thread_raise(1, &exc, th);
|
||||
}
|
||||
|
|
25
io.c
25
io.c
|
@ -710,7 +710,7 @@ rb_io_fread(ptr, len, f)
|
|||
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
|
||||
case EWOULDBLOCK:
|
||||
#endif
|
||||
if (len - n >= 0) {
|
||||
if (len - n >= 0) {
|
||||
clearerr(f);
|
||||
return len - n;
|
||||
}
|
||||
|
@ -1385,15 +1385,22 @@ rb_io_close(io)
|
|||
VALUE io;
|
||||
{
|
||||
OpenFile *fptr;
|
||||
int fd;
|
||||
int fd, fd2;
|
||||
|
||||
fptr = RFILE(io)->fptr;
|
||||
if (!fptr) return Qnil;
|
||||
if (!fptr->f && !fptr->f2) return Qnil;
|
||||
if (fptr->f2) {
|
||||
fd2 = fileno(fptr->f2);
|
||||
}
|
||||
else {
|
||||
if (!fptr->f) return Qnil;
|
||||
fd2 = -1;
|
||||
}
|
||||
|
||||
fd = fileno(fptr->f);
|
||||
rb_io_fptr_cleanup(fptr, Qfalse);
|
||||
rb_thread_fd_close(fd);
|
||||
if (fd2 >= 0) rb_thread_fd_close(fd2);
|
||||
|
||||
if (fptr->pid) {
|
||||
rb_syswait(fptr->pid);
|
||||
|
@ -1953,7 +1960,6 @@ pipe_del_fptr(fptr)
|
|||
}
|
||||
}
|
||||
|
||||
#if defined (_WIN32) || defined(DJGPP) || defined(__CYGWIN__) || defined(__human68k__) || defined(__VMS)
|
||||
static void
|
||||
pipe_atexit _((void))
|
||||
{
|
||||
|
@ -1966,7 +1972,6 @@ pipe_atexit _((void))
|
|||
list = tmp;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void pipe_finalize _((OpenFile *fptr,int));
|
||||
|
||||
|
@ -2351,7 +2356,9 @@ io_reopen(io, nfile)
|
|||
else if (orig->mode & FMODE_WRITABLE) {
|
||||
io_fflush(orig->f, orig);
|
||||
}
|
||||
rb_thread_fd_close(fileno(fptr->f));
|
||||
if (fptr->mode & FMODE_WRITABLE) {
|
||||
io_fflush(GetWriteFile(fptr), fptr);
|
||||
}
|
||||
|
||||
/* copy OpenFile structure */
|
||||
fptr->mode = orig->mode;
|
||||
|
@ -2364,7 +2371,7 @@ io_reopen(io, nfile)
|
|||
|
||||
mode = rb_io_mode_string(fptr);
|
||||
fd = fileno(fptr->f);
|
||||
if (fd < 3) {
|
||||
if (fd == fileno(stdin) || fd == fileno(stdout) || fd == fileno(stderr)) {
|
||||
clearerr(fptr->f);
|
||||
/* need to keep stdio objects */
|
||||
if (dup2(fileno(orig->f), fd) < 0)
|
||||
|
@ -2376,14 +2383,16 @@ io_reopen(io, nfile)
|
|||
rb_sys_fail(orig->path);
|
||||
fptr->f = rb_fdopen(fd, mode);
|
||||
}
|
||||
rb_thread_fd_close(fd);
|
||||
if ((orig->mode & FMODE_READABLE) && pos >= 0) {
|
||||
io_seek(fptr, pos, SEEK_SET);
|
||||
io_seek(orig, pos, SEEK_SET);
|
||||
}
|
||||
|
||||
if (fptr->f2) {
|
||||
if (fptr->f2 && fd != fileno(fptr->f2)) {
|
||||
fd = fileno(fptr->f2);
|
||||
fclose(fptr->f2);
|
||||
rb_thread_fd_close(fd);
|
||||
if (orig->f2) {
|
||||
if (dup2(fileno(orig->f2), fd) < 0)
|
||||
rb_sys_fail(orig->path);
|
||||
|
|
Загрузка…
Ссылка в новой задаче