diff options
| author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-25 04:29:30 +0000 |
|---|---|---|
| committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-25 04:29:30 +0000 |
| commit | 4be84ede7ca146167f59346780ee76f6d7d2d48c (patch) | |
| tree | e1115f21a0a9a9a3c23e7a0433a7509b567f4fec | |
| parent | 834e9bdf1c0f4d7bd85466fd4cc6b52f5bae7a3d (diff) | |
| download | ruby-4be84ede7ca146167f59346780ee76f6d7d2d48c.tar.gz ruby-4be84ede7ca146167f59346780ee76f6d7d2d48c.tar.xz ruby-4be84ede7ca146167f59346780ee76f6d7d2d48c.zip | |
* io.c (rb_io_flush): fsync() after buffer is flushed on win32.
[ruby-core:20043]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@20982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | io.c | 15 |
2 files changed, 18 insertions, 2 deletions
@@ -1,3 +1,8 @@ +Thu Dec 25 13:28:20 2008 NAKAMURA Usaku <usa@ruby-lang.org> + + * io.c (rb_io_flush): fsync() after buffer is flushed on win32. + [ruby-core:20043] + Thu Dec 25 13:13:00 2008 Koichi Sasada <ko1@atdot.net> * vm_insnhelper.c (vm_method_search): return rb_cObject if there is no @@ -983,6 +983,9 @@ rb_io_flush(VALUE io) if (fptr->mode & FMODE_WRITABLE) { io_fflush(fptr); +#ifdef _WIN32 + fsync(fptr->fd); +#endif } if (fptr->mode & FMODE_READABLE) { io_unread(fptr); @@ -4416,7 +4419,9 @@ popen_redirect(struct popen_arg *p) } } } +#endif +#if defined(HAVE_FORK) || defined(_WIN32) void rb_close_before_exec(int lowfd, int maxhint, VALUE noclose_fds) { @@ -4433,12 +4438,16 @@ rb_close_before_exec(int lowfd, int maxhint, VALUE noclose_fds) if (ret != -1 && !(ret & FD_CLOEXEC)) { fcntl(fd, F_SETFD, ret|FD_CLOEXEC); } +#elif defined(_WIN32) + rb_w32_fd_noinherit(fd); #else close(fd); #endif } } +#endif +#ifdef HAVE_FORK static int popen_exec(void *pp, char *errmsg, size_t errmsg_len) { @@ -5922,13 +5931,15 @@ rb_io_initialize(int argc, VALUE *argv, VALUE io) fd = NUM2INT(fnum); UPDATE_MAXFD(fd); - if (NIL_P(vmode)) { #if defined(HAVE_FCNTL) && defined(F_GETFL) + if (NIL_P(vmode)) { oflags = fcntl(fd, F_GETFL); if (oflags == -1) rb_sys_fail(0); fmode = rb_io_oflags_fmode(oflags); -#endif } +#elif defined(_WIN32) + if (rb_w32_is_valid_fd(fd)) rb_sys_fail(0); +#endif MakeOpenFile(io, fp); fp->fd = fd; fp->mode = fmode; |
