summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorksss <[email protected]>2017-05-21 16:58:57 +0900
committerksss <[email protected]>2017-05-21 17:10:15 +0900
commitc43795c6648546eecf92e22150b7e478e63e1a31 (patch)
tree65bc0160624a01c292c6a1856a6e4cab1323f38e
parent6836f424c5ff95d0114a426010b22254804bc9a3 (diff)
downloadmruby-c43795c6648546eecf92e22150b7e478e63e1a31.tar.gz
mruby-c43795c6648546eecf92e22150b7e478e63e1a31.zip
Should raise SyscallError on IO#syswrite
instead of IOError
-rw-r--r--mrblib/io.rb9
-rw-r--r--src/io.c3
2 files changed, 5 insertions, 7 deletions
diff --git a/mrblib/io.rb b/mrblib/io.rb
index 08f9180dd..694fdb0c9 100644
--- a/mrblib/io.rb
+++ b/mrblib/io.rb
@@ -123,14 +123,9 @@ class IO
def write(string)
str = string.is_a?(String) ? string : string.to_s
return str.size unless str.size > 0
-
len = syswrite(str)
- if len != -1
- @pos += len
- return len
- end
-
- raise IOError
+ @pos += len
+ len
end
def <<(str)
diff --git a/src/io.c b/src/io.c
index 51a659f0e..452a61a3f 100644
--- a/src/io.c
+++ b/src/io.c
@@ -705,6 +705,9 @@ mrb_io_syswrite(mrb_state *mrb, mrb_value io)
fd = fptr->fd2;
}
length = write(fd, RSTRING_PTR(buf), RSTRING_LEN(buf));
+ if (length == -1) {
+ mrb_sys_fail(mrb, 0);
+ }
return mrb_fixnum_value(length);
}