summaryrefslogtreecommitdiff
path: root/io.c
AgeCommit message (Collapse)Author
2015-09-15encindex.h: ENCINDEXnobu
* encindex.h: separate encoding index constants from internal.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-09io.c: sys/wait.hnobu
* io.c: BSDs need sys/wait.h for WNOHANG. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-08io.c: no wait when killednobu
* io.c (rb_io_s_popen): do not wait the child process during being killed. [ruby-core:70671] [Bug #11510] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-19io.c: initialize variablenobu
* io.c (rb_io_each_codepoint): fix use of uninitialized variable. [Bug #11444] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-17io.c: raise at incomplete charnobu
* io.c (rb_io_each_codepoint): raise an exception at incomplete character before EOF when conversion takes place. [Bug #11444] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-15io.c: read more datanobu
* io.c (rb_io_each_codepoint): read more data when read partially. [ruby-core:70379] [Bug #11444] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-29* io.c (rb_io_extract_modeenc): add option parameter `flags'naruse
to append extra oflags to normal mode. [Feature #11253] [ruby-core:69539] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-20io.c: IO.copy_stream uses poll on Linuxnormal
poll and ppoll have a superior API which doesn't require the kernel to scan a potentially large bitmap to find a high-numbered FD [ruby-core:35572]. So favor using poll in case IO.copy_stream encounters a non-blocking FD. We cannot reliably use poll on most OSes, because file types (e.g. FIFOs) which work with select may not work with poll. Fortunately, Linux uses a common notification mechanism between all select/poll/epoll variants, so all file types are equally supported between the notification mechanisms. Verified by watching strace on the following scripts: *** maygvl_copy_stream_wait_read *** require 'io/nonblock' r, w = IO.pipe r.nonblock = true IO.copy_stream(r, "/dev/null") *** nogvl_copy_stream_wait_write *** require 'io/nonblock' r, w = IO.pipe w.nonblock = true IO.copy_stream("/dev/zero", w) * io.c (nogvl_wait_for_single_fd): new function for Linux (maygvl_copy_stream_wait_read): Linux-specific version (nogvl_copy_stream_wait_write): use nogvl_wait_for_single_fd [ruby-core:70051] [Feature #11377] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-17io.c (argf_read_nonblock): support `exception: false'normal
This is a preparation for [ruby-core:69892] ("io.c: avoid kwarg parsing in C API") since I noticed ARGF.read_nonblock did not properly catch up to the `exception: false' change. * io.c (argf_read_nonblock): support `exception: false' (io_nonblock_eof): new function (io_read_nonblock): use io_nonblock_eof (argf_getpartial): accept kwargs hash for `exception: false' * test/ruby/test_argf.rb (test_read_nonblock): new test [ruby-core:70000] [Feature #11358] * NEWS: add item for ARGF.read_nonblock git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-12* ext/socket/basicsocket.c: [DOC] typo (Errno::AGAIN -> Errno::EAGAIN)sorah
* ext/socket/socket.c: ditto * ext/socket/tcpserver.c: ditto * ext/socket/udpsocket.c: ditto * ext/socket/unixserver.c: ditto * io.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-02delay `exception: false' checks for minor speedupnormal
Delay hash lookups until we are about to hit an exception. This gives a minor speedup ratio of 2-3% in the new bm_io_nonblock_noex benchmark as well as reducing code. * benchmark/bm_io_nonblock_noex.rb: new benchmark * ext/openssl/ossl_ssl.c (no_exception_p): new function (ossl_start_ssl): adjust for no_exception_p (ossl_ssl_connect): adjust ossl_start_ssl call (ossl_ssl_connect_nonblock): ditto (ossl_ssl_accept): ditto (ossl_ssl_accept_nonblock): ditto (ossl_ssl_read_internal): adjust for no_exception_p (ossl_ssl_write_internal): ditto (ossl_ssl_write): adjust ossl_write_internal call (ossl_ssl_write_nonblock): ditto * ext/stringio/stringio.c (strio_read_nonblock): delay exception check * io.c (no_exception_p): new function (io_getpartial): call no_exception_p (io_readpartial): adjust for io_getpartial (get_kwargs_exception): remove (io_read_nonblock): adjust for io_getpartial, check no_exception_p on EOF (io_write_nonblock): call no_exception_p (rb_io_write_nonblock): do not check `exception: false' (argf_getpartial): adjust for io_getpartial [ruby-core:69778] [Feature #11318] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-30io.c: remove unnecessary sharednobu
* io.c (rb_io_reopen): FilePathValue() ensures the path NUL-terminated and frozen, so it is unnecessary to make it shared. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-30ensure paths NUL-terminatednobu
* dir.c (check_dirname): ensure path name NUL-terminated for SHARABLE_MIDDLE_SUBSTRING. * io.c (rb_sysopen): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-30io.c: reopen OS encoding pathnobu
* io.c (rb_io_reopen): freopen(3) with OS encoding path. [ruby-core:69780] [Bug #11320] * win32/file.c (rb_freopen): wrapper of wchar version freopen(3). use _wfreopen_s() if available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-29io.c: reopen stdio streams correctly when given "w+"normal
* io.c (rb_io_oflags_modestr): handle O_TRUNC correctly * test/ruby/test_io.rb (test_reopen_stdio): new test Patch-by: cremno phobia <cremno@mail.ru> [ruby-core:69779] [Bug #11319] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51066 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-18* include/ruby/ruby.h: $SAFE=2 is now obsolete.hsbt
* dir.c, ext/fiddle/handle.c, ext/socket/basicsocket.c, file.c gc.c, io.c, process.c, safe.c, signal.c, win32/file.c: removed code for $SAFE=2 * test/erb/test_erb.rb, test/fiddle/test_handle.rb test/ruby/test_env.rb: removed tests for $SAFE=2. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-13* io.c (rb_io_s_binread): close fd if seek offset is invalid.eregon
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-13io.c: simplify rb_io_modestr_fmodenobu
* io.c (io_encname_bom_p): needs len always. * io.c (rb_io_modestr_fmode): check BOM only after a colon. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-04io.c: reduce size of :wait_*able code pathsnormal
* io.c (sym_wait_readable, sym_wait_writable): declare (io_getpartial): use sym_wait_readable (io_write_nonblock): use sym_wait_writable (Init_IO): initialize sym_wait_*able On 32-bit x86: text data bss dec hex filename 121003 56 252 121311 1d9df io.o 121035 56 252 121343 1d9ff io.o.orig git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-25io.c: refine messagenobu
* io.c (prepare_getline_args): refine the expected arity in an exception message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50636 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-21Fixes for grammar and style [ci skip]nobu
* io.c (rb_f_select): [DOC] Fixes for grammar and style. [Fix GH-906] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-09* internal.h (rb_execarg_parent_end): Declared.akr
* process.c: "spawn" opens files in the parent process. (check_exec_redirect): Add an placeholder for fd in parameters for fd_open. (check_exec_fds_1): Delete fd_open condition. (check_exec_fds): Don't call check_exec_fds_1 with fd_open. (rb_execarg_parent_start): Open files specified as "spawn" options and add "dup2" options. (rb_execarg_parent_end): New function to close opened fds. (run_exec_open): Removed. (rb_execarg_run_options): Don't call run_exec_open. (rb_spawn_internal): Call rb_execarg_parent_end. * io.c (pipe_open): Call rb_execarg_parent_end. * ext/pty/pty.c (establishShell): Call rb_execarg_parent_end. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-09* internal.h (rb_execarg_parent_start): Renamed from rb_execarg_fixup.akr
* process.c: Follows the above change. * io.c: Ditto. * ext/pty/pty.c: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-30io.c: use read/write methods if possiblenobu
* io.c (copy_stream_body): use the arguments without conversion if having read, readpartial, and write methods, than conversion by to_path method. [ruby-core:68676] [Bug #11015] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-21console.c: winsize on Windowsnobu
* ext/io/console/console.c (console_set_winsize): use handle for writing. GetConsoleScreenBufferInfo seems failing on a handle for reading. * io.c: [DOC] update the example of IO#winsize to use $stdout instead of $stdin, which does not work on Windows. a patch by Jan Lelis <mail AT janlelis.de> at [ruby-core:68574]. [Bug #10986] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-13io.c: don't raise after closenobu
* io.c (rb_io_close_read, rb_io_close_write): don't raise after close same as IO#close. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-13io.c: rb_io_get_fptrnobu
* io.c (rb_io_get_fptr): return non-null fptr. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-09io.c: duplicate codenobu
* io.c (rb_io_close_m): remove duplicate check. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49901 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-27io.c: wipe away ioctl buffernobu
* io.c (setup_narg): wipe away expanded part of buffer to get rid of revealing uncleaned data. reported by Dongkwan Kim <dkay AT kaist.ac.kr>. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-27io.c: discard buffer alwaysnobu
* io.c (copy_stream_fallback_body): discard buffer always before exit or exception. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-26io.c: redulce RSTRING_PTR and RSTRING_LENnobu
* io.c: replace repeating RSTRING_PTR and RSTRING_LEN with local variables. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-15* io.c (rb_io_close_m): Don't raise when the IO object is closed.akr
[ruby-core:67444] [Feature #10718] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-29io.c: workaround for YARD docnobu
* io.c (rb_f_select): [DOC] workaround for YARD doc. [Fix GH-799] [ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-11io.c: Fix spelling [ci skip]nobu
* io.c (io_read) Fix spelling in docco for read. [Fix GH-781] try > tries git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-07io.c: Typo close -> closes.hone
Patch by @cirosantilli [Fixes GH-757] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48735 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-05io.c: fix rdoc [ci skip]nobu
* io.c (Init_IO): ARGF is not a class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-01use 0 for reservednobu
use 0 for rb_data_type_t::reserved instead of NULL, since its type may be changed in the future and possibly not a pointer type. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-28* eval_error.c (error_print): respect the encoding of the message.usa
* io.c (rb_write_error_str): use rb_w32_write_console() on Windows if stderr is a tty. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-23io.c: preserve encodingsnobu
* io.c (must_respond_to): preserve encodings of variable name and class name in warning message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-22io.c: remove redundant assignmentnobu
* io.c (rb_io_sysread): Remove redundan assignment of 'n'. [Fix GH-767] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-18* internal.h: Gather declarations in non-header files.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-18* include/ruby/io.h (FMODE_WSPLIT): Removed. The write() system callakr
is not required to split. It was useful to avoid whole process blocking in Ruby 1.8 but not useful since write() is invoked without GVL. (FMODE_WSPLIT_INITIALIZED): Ditto. * io.c (wsplit_p): Removed. (io_writable_length): Removed. (rb_fcntl): Don't update the removed flags. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-16id.def: move IDs for exceptionnobu
* defs/id.def: add :mesg and :exception and move from other sources. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15* internal.h: Include ruby.h and ruby/encoding.h to beakr
includable without prior inclusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-10* win32/win32.c, include/win32/win32.h (rb_w32_set_nonblock): newusa
function to support nonblock-mode of pipes. * win32/win32.c (rb_w32_read): nonblock-mode pipe returns ERROR_NO_DATA if there is no data, but also returns it if remote-end is closed. * win32/win32.c (rb_w32_write): if cannot to write any data, it may be blocking. * io.c (rb_io_set_nonblock): use rb_w32_set_nonblock for Windows. * ext/io/nonblock/nonblock.c (rb_io_nonblock_set): use ruby's API when setting nonblock-mode. * test/ruby/test_io.rb: test nonblock pipes on Windows. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-25* io.c (io_binwrite_string): Test writev() failure.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-20io.c: enclose statements by ifdefnobu
* io.c (maygvl_copy_stream_read): enclose following statements by ifdef, not only a case label. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-11Fixes build failures on Portable Native Client.yugui
Note: Some of the fixes are for newlib in general but not NaCl-specific. * include/ruby/intern.h (rb_fd_select): declare struct timeval, or the struct gets local to the function in C99. * file.c (#include): add nacl/stat.h for PNaCl. (utimes): added a declaration for PNaCl. (stat_atimespec): stat::st_atimensec is long long but timespec::tv_nsec is long in PNaCl. (stat_mtimespec, stat_ctimespec): ditto. (rb_group_member): disable getgroups unless HAVE_GETGROUPS. (eaccess): unify the fallback to generic defined(USE_GETEUID). * io.c: include sys/time.h for struct timeval. (rb_close_before_exec): nothing we can do if F_GETFD is not available. (ioctl): pnacl newlib actually doesn't have ioctl. * process.c (maxgroups): it is used iff defined(_SC_NGROUPS_MAX) || defined(NGROUPS_MAX) but not defined(HAVE_GETGROUPS) || defined(HAVE_SETGROUPS). (obj2gid): fail unless the object is a Fixnum if getgrnam is not available. (disable_child_handler_fork_child): sigaction is not available in PNaCl newlib. * configure.in (warnflags, strict_warnflags): avoid -ansi for strlcpy. (rb_cv_gcc_atomic_builtins): also check __atomic_or_etch because it is used in ruby_atomic.h. (rb_cv_gcc_sync_builtins): ditto. (HAVE_GETGRNAM): added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-11* io.c: fix issues in the last two commits. don't disable cloexec foryugui
platforms other than NativeClient. * ChangeLog: ditto. add entries for the last two commits. Sat Oct 11 11:12:00 2014 Yuki Yugui Sonoda <yugui@yugui.jp> * signal.c (install_signalhandler, init_sigchld): allow failure because it always fails with ENOSYS on NaCl. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-11Allow failure of sighandler installation on NativeClient.yugui
* signal.c (install_signalhandler, init_sigchld): allow failure because it always fails with ENOSYS on NaCl. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e