diff options
author | Benoit Daloze <[email protected]> | 2019-12-27 16:46:08 +0100 |
---|---|---|
committer | Benoit Daloze <[email protected]> | 2019-12-27 16:46:08 +0100 |
commit | a2fac1d72c225192018f8f3f3dfcfcc46f66c08a (patch) | |
tree | dc2d44079962ce242d971a4d1c2a2b1333e64cec /spec/ruby/optional/capi/ext/io_spec.c | |
parent | 26a9f80c823a9f536a235d80d600aa9e03ed7a2f (diff) |
Update to ruby/spec@d419e74
Diffstat (limited to 'spec/ruby/optional/capi/ext/io_spec.c')
-rw-r--r-- | spec/ruby/optional/capi/ext/io_spec.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/ruby/optional/capi/ext/io_spec.c b/spec/ruby/optional/capi/ext/io_spec.c index b656de081a..45f57810db 100644 --- a/spec/ruby/optional/capi/ext/io_spec.c +++ b/spec/ruby/optional/capi/ext/io_spec.c @@ -201,6 +201,19 @@ VALUE io_spec_rb_io_close(VALUE self, VALUE io) { return rb_io_close(io); } +VALUE io_spec_rb_io_set_nonblock(VALUE self, VALUE io) { + rb_io_t* fp; + int flags; + GetOpenFile(io, fp); + rb_io_set_nonblock(fp); +#ifdef F_GETFL + flags = fcntl(fp->fd, F_GETFL, 0); + return flags & O_NONBLOCK ? Qtrue : Qfalse; +#else + return Qfalse; +#endif +} + /* * this is needed to ensure rb_io_wait_*able functions behave * predictably because errno may be set to unexpected values @@ -225,6 +238,7 @@ void Init_io_spec(void) { rb_define_method(cls, "rb_io_check_readable", io_spec_rb_io_check_readable, 1); rb_define_method(cls, "rb_io_check_writable", io_spec_rb_io_check_writable, 1); rb_define_method(cls, "rb_io_check_closed", io_spec_rb_io_check_closed, 1); + rb_define_method(cls, "rb_io_set_nonblock", io_spec_rb_io_set_nonblock, 1); rb_define_method(cls, "rb_io_taint_check", io_spec_rb_io_taint_check, 1); rb_define_method(cls, "rb_io_wait_readable", io_spec_rb_io_wait_readable, 2); rb_define_method(cls, "rb_io_wait_writable", io_spec_rb_io_wait_writable, 1); |