summaryrefslogtreecommitdiff
path: root/io.c
AgeCommit message (Collapse)Author
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
2014-10-11Merges a patch form naclports.yugui
* configure.in (RUBY_NACL and others): Supports PNaCl. * dln.c: replace the old hacky dynamic loading over HTTP with nacl_io. * file.c: tenatively use access(2) instead of eaccess. (rb_file_load_ok): weaken with attribute but not by postprocess. * io.c (socket.h): now NaCl has socket.h (flock): disable here instead of nacl/ioctl.h * nacl/GNUmakefile.in (CC, LD, NM, AR, AS, RANLIB, OBJDUMP, OBJCOPY): respect path to them if they are absolute. This helps naclports to build ruby in their source tree. (PROGRAM_NMF, .SUFFIXES): support .pnexe for PNaCl. (ruby.o, file.o): move the hack to attributes in ruby.c and file.c * nacl/ioctl.h: removed. move the hack to io.c. * nacl/nacl-config.rb: support arm, pnacl and others. * nacl/pepper_main.c: support build in a naclports tree. * ruby.c (rb_load_file): weaken with attribute but not by postprocess. The patch is by sbc@google.com and the Native Client Authors. It is available at: * https://chromium.googlesource.com/external/naclports.git/+/873ca4910a5f9d4206306aacb4ed79c587c6a5f3/ports/ruby/nacl.patch git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-10io.c: fix typonobu
* io.c (rb_io_make_open_file): remove useless backslash. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-10io.c: move RFile initializationnobu
* io.c (rb_io_make_open_file): move from include/ruby/io.h, and hide too detailed implementations. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-05io.c: ID instead of Symbolnobu
* io.c (get_kwargs_exception): rb_get_kwargs() expects IDs, but not Symbols. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-01io.c (fptr_finalize): free memory before GC sweepnormal
This releases memory on explict calls to rb_io_close, reducing pressure on the GC. Final massif snapshot shows reduced heap usage after RubyGems load (valgrind --tool=massif ./ruby -e exit) before: mem_heap_B=4821992 mem_heap_extra_B=1302952 after: mem_heap_B=4791056 mem_heap_extra_B=1192440 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-25io.c: common function to free IO buffersnormal
This also allows easier tracking of freed memory for systems without malloc_usable_size, and also makes future changes to freeing buffer memory easier-to-implement. * io.c (free_io_buffer): new function for a common pattern (clear_readconv): use free_io_buffer (rb_io_fptr_finalize): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-15trivial packing for on-stack structsnormal
* io.c (struct io_advise_struct): 32 => 24 bytes on 64-bit * io.c (struct io_internal_writev_struct): 24 => 16 bytes on 64-bit * process.c (struct waitpid_arg): ditto Slightly reduce stack pressure. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-02* configure.in: Use AC_FUNC_FORK.akr
* io.c: Use HAVE_WORKING_FORK instead of HAVE_FORK. * process.c: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-28io.c: fix uninitialized variablenobu
* io.c (argf_next_argv): fix uninitialized variable in skipping message when inplace edit without backup. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-28io.c: preserve encodingsnobu
* io.c (argf_next_argv): preserve encodings in warning messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-28io.c: preserve encodingsnobu
* io.c (rb_io_extract_encoding_option): preserve encodings in warning messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-28io.c: preserve encodingsnobu
* io.c (advice_arg_check): preserve encodings in warning messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-28io.c: preserve encodingsnobu
* io.c (rb_io_s_new): preserve encodings in warning messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-26io.c: do not swallow exceptions at end of blocknobu
* io.c (io_close): ignore only "closed stream" IOError and NoMethodError, do not swallow other exceptions at the end of block. [ruby-core:64463] [Bug #10153] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47288 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-25introduce ZALLOC{,_N} to replace ALLOC{,_N}+MEMZERO usenormal
Using calloc where possible reduces code and binary sizes. * include/ruby/ruby.h (ZALLOC, ZALLOC_N): implement (Data_Make_Struct, TypedData_Make_Struct): ZALLOC replaces ALLOC+memset * compile.c (iseq_seq_sequence): ZALLOC_N replaces ALLOC_N+MEMZERO * cont.c (fiber_t_alloc): ZALLOC replaces ALLOC+MEMZERO * io.c (rb_io_reopen): ditto * iseq.c (prepare_iseq_build): ditto * parse.y (new_args_tail_gen, parser_new, ripper_s_allocate): ditto * re.c (match_alloc): ditto * variable.c (rb_const_set): ditto * ext/socket/raddrinfo.c (get_addrinfo): ditto * ext/strscan/strscan.c (strscan_s_allocate): ditto * gc.c (rb_objspace_alloc): calloc replaces malloc+MEMZERO git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-19io.c: fix rdoc of append modenobu
* io.c (rb_io_initialize): [DOC] fix rdoc of append mode. it does not move the pointer at open. [ruby-core:63747] [Bug #10039] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-11* io.c: Improve Documentation by @dapplebeforedawn.hsbt
[fix GH-658] [ruby-core:63579] [Bug #10012] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-09io.c: refine error messagenobu
* io.c (do_io_advise): more precise error message, with arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-18constify parametersnobu
* include/ruby/intern.h: constify `argv` parameters. * include/ruby/ruby.h: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e