summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/io.c b/io.c
index f6ea3a1154..7e4de96334 100644
--- a/io.c
+++ b/io.c
@@ -431,6 +431,14 @@ io_fwrite(str, fptr)
) {
#ifdef __hpux
if (!errno) errno = EAGAIN;
+#elif defined(_WIN32) && !defined(__BORLANDC__)
+ /* workaround for MSVCRT's bug */
+ if (!errno) {
+ if (GetLastError() == ERROR_NO_DATA)
+ errno = EPIPE;
+ else
+ errno = EBADF;
+ }
#endif
if (rb_io_wait_writable(fileno(f))) {
rb_io_check_closed(fptr);