Should raise SyscallError on IO#syswrite

instead of IOError
This commit is contained in:
ksss
2017-05-21 16:58:57 +09:00
parent 6836f424c5
commit c43795c664
2 changed files with 5 additions and 7 deletions
+2 -7
View File
@@ -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)
+3
View File
@@ -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);
}