(ARGVSTR2ARGV): defined.
* process.c (proc_exec_v): use ARGVSTR2ARGV.
(rb_spawn_process): use ARGVSTR2ARGC and ARGVSTR2ARGV.
* io.c (pipe_open): use ARGVSTR2ARGV.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c (pipe_open): argc and argv are not used on win32.
* process.c (rb_spawn_process): remove already useless variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (proc_spawn_n): now uses char ** instead of VALUE *.
* process.c (rb_spawn_process): prog is now VALUE of String, not char *.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Patch by Google Inc. [ruby-core:45073].
* configure.in (RUBY_NACL): New M4 func to configure variables for
NaCl.
(RUBY_NACL_CHECK_PEPPER_TYPES): New M4 func to check the old names
of Pepper interface types.
(BTESTRUBY): New variable to specify which ruby should be run on
"make btest". NaCl can run the built binary by sel_ldr, but it need
rbconfig.rb. So this variable is distinguished from $MINIRUBY.
* thread_pthread.c: Disabled some features on NaCl.
* io.c: ditto.
* process.c: ditto.
* signal.c: ditto.
* file.c: ditto.
* missing/flock.c: ditto.
* nacl/pepper_main.c: An example implementation of Pepper application
that embeds Ruby.
* nacl/example.html: An example of web page that uses the Pepper
application.
* nacl/nacl-config.rb: Detects variants of NaCl SDK.
* nacl/GNUmakefile.in: Makefile template for NaCl specific build
process.
* nacl/package.rb: script for packaging a NaCl-Ruby embedding
application.
* nacl/reate_nmf.rb: Wrapper script of create_nmf.py
* dln.c (dln_load): Added a hack to call on NaCl.
* util.c (ruby_getcwd): Path to the current directort is not available
on NaCl.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
If the end of reading buffer is CR, io_unread() needs to unread one
more byte.
[ruby-core:44874] [Bug #6401]
* test/ruby/test_io_m17n.rb (TestIO_M17N#test_pos_with_buffer_end_cr):
add a test for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
this tmp1 is not required after r35538.
* addr2line.c: suppress warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
io_unread() doesn't work properly when reading CRLF with read(length)
and mode 'r'.
[ruby-core:44189][Bug #6271]
* test/ruby/test_io_m17n.rb (TestIO_M17N#test_read_crlf_and_eof):
test for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Use it in set_binary_mode_with_seek_cur().
* io.c (set_binary_mode_with_seek_cur): refactoring to split the
content into io_unread(). Fix the possibility of buffer overflow.
* io.c (io_unread): add new implementation for Windows. Previous one
caused invalid cursor position using IO#pos with OS text mode. New
one fixes the bug.
* test/ruby/test_io_m17n.rb
(TestIO_M17N#test_pos_dont_move_cursor_position): add a test for
above bug.
[ruby-core:43497] [Bug #6179]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
arbitrary object as a pointer to rb_encoding, and return NULL if
not found.
* io.c (io_encoding_set): just warn unsupported encodings, but not
exception. [ruby-core:40726] [Bug #5567]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
after check if readable, which can cause thread switch.
[ruby-dev:45297][Bug #6099]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
[ruby-dev:45160] [Bug #5952]
* io.c (argf_readlines): reinitialize after all read to be
readable again.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
is specified with both vmode and opthash.
[ruby-core:42199] [Bug #5918]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Move above for using it in set_binary_mode_with_seek_cur().
* io.c (set_binary_mode_with_seek_cur): fix improper seek cursor.
Seeking file cursor with setting binary mode has possibility to
cause infinite loop. Fixed the bug and refined error handling.
Introduced at r34043.
And cleanups as below.
Remove unnecessary parentheses of `fptr`.
Use return value of setmode().
* test/ruby/test_io_m17n.rb
(TestIO_M17N#test_seek_with_setting_binmode): add a test for abobe.
[ruby-core:41671] [Bug #5714]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* win32/win32.c (init_stdhandle): set default mode of stdin as binmode.
* io.c (set_binary_mode_with_seek_cur): new function to replace
SET_BINARY_MODE_WITH_SEEK_CUR macro. now returns previous mode of the
fd and take care of LF in rbuf.
* io.c (do_writeconv): set text mode when needed.
* io.c (io_read): need to change the mode of the IO to binmode
temporally when the length for IO#read, because IO#read with length
must behave so.
* test/ruby/test_io_m17n.rb (TestIO_M17N#est_{read_with_length,
read_with_length_binmode,get[cs]_and_read_with_binmode,
read_with_binmode_and_get[cs],read_write_with_binmode}): tests for
above changes.
all patches are written by Hiroshi Shirosaki. [ruby-core:41496]
[Feature #5714]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/io/console/console.c: Mention that io/console must be required
similar to lib/time.rb
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Use CRLF only when required to improve file reading and writing under Windows.
Patch by Hiroshi Shirosaki. [ruby-core:40706] [Feature #5562]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
specific narg length calculation.
* test/ruby/test_io.rb (test_ioctl_linux2): add new test for old and
unstructured ioctl.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
On Linux some constants for ioctl(2) doesn't include the size of
its return value and 16bit value; for example FIONREAD 0x541B.
Moreover the manual, ioctl_list(2), says "Note that the size
bits are very unreliable: in lots of cases they are wrong,
either because of buggy macros using sizeof(sizeof(struct)),
or because of legacy values."
So we shouldn't use it.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
available (for Windows).
* win32/win32.c (fcntl): on F_DUPFD, determine the inheritance of the
new handle by O_NOINHERIT flag of original fd.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
fixed the failure of TestArgf#test_textmode introduced at r33662.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
It may change string value meaning if the value is string.
(e.g. MacOS X has F_GETPATH ioctl)
* io.c (rb_fcntl): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Moreover almost all linux ioctl can't be represented by 32bit integer
(i.e. MSB is 1). We need wrap ioctl argument type.
[Bug #5429] [ruby-dev:44589]
* io.c (struct ioctl_arg): ditto.
* io.c (rb_ioctl): ditto.
* test/ruby/test_io.rb (test_ioctl_linux): add a testcase for ioctl
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c (rb_io_ctl): don't use ioctl specific length check
if caller is fcntl.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33711 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
set. this is the one of the reason of IO writing slowness of Windows
in 1.9.3 or later.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
ECONV_NEWLINE_DECORATOR_WRITE_MASK): new macro.
* io.c (rb_io_extract_modeenc, pipe_open, prep_stdio, argf_next_argv):
set TEXTMODE_NEWLINE_DECORATOR_ON_WRITE for textmode on creating IO
if the flag is available.
* io.c (make_writeconv): drop decorators for reading.
* io.c (make_readconv): drop decorators for writing.
* io.c (do_writeconv): existing writeconv is not the condition to raise
ArgumentError. should check textmode or not.
* test/ruby/test_io_m17n.rb
(TestIO_M17N#test_{cr,lf,crlf}_decorator_on_stdout): test above
changes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c (rb_io_flush, rb_io_rewind): fsync() here.
these changes reduces fsync() calls to improve performance.
first reported at [ruby-list:48515] by ak7 at mail.goo.ne.jp .
[Bug #5585]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
so, if the io is text mode and has ECONV_UNIVERSAL_NEWLINE_DECORATOR
flag, use crlf_newline converter for writing.
this change fixes the problem about the luck of CR up Kernel.p and
Kernel.puts to stdout/stderr on Windows.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
descriptors.
(rb_cloexec_dup): use rb_cloexec_fcntl_dupfd.
(rb_cloexec_fcntl_dupfd): use F_DUPFD_CLOEXEC if available.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c (nogvl_io_cntl): use rb_cloexec_fcntl_dupfd() only if the
platform has F_DUPFD.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c (fd_set_cloexec): extracted from rb_fd_set_cloexec.
(rb_cloexec_open): new function.
(sysopen_func): use rb_cloexec_open.
(rb_sysopen_internal): use rb_update_max_fd instead of
rb_fd_set_cloexec.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
[Bug #5153] [ruby-core:38736]
* io.c (argf_next_argv): remove the call of above function.
* ext/-test-/add_suffix, test/-ext-/test_add_suffix.rb: remove the test
extension module because this is only for testsing ruby_add_suffix().
* LEGAL: remove the mention about a part of util.c, because now we
removed the part.
* io.c (argf_next_argv): now the new filename is not guranteed to
use, so should check the return value of rename(2).
* test/ruby/test_argf.rb (TestArgf#test_inplace_rename_impossible):
now we expect same result with other platforms on no_safe_rename
platforms (=Windows).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
from rb_w32_has_cancel_io(). now it takes a parameter as fd to check
the fd is console or not, because we cannot cancel console input even
if we have cancel_io function.
* io.c (WAIT_FD_IN_WIN32): call above function instead of the old one,
so now we can kill the thread which calls STDIN.gets.
the problem was reported by ko1 vir IRC.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
RB_RESERVED_FD_P): added. This C API is to limit to access
fds which are used by RubyVM internal. In this version of
CRuby, return 1 if fd is communication pipe.
If your application needs to close all file descriptors to
preent resource leak, skip internal fds using this C API.
We also define a macro RB_RESERVED_FD_P(fd). So you can write
#ifndef RB_RESERVED_FD_P
#define RB_RESERVED_FD_P(fd) 0
#endif
for Ruby 1.9.2 or previous version to write compatible extensions.
See [ruby-core:37727]
* thread_win32.c (rb_reserved_fd_p): added (return 0 for any fds).
* io.c (rb_io_initialize): raise ArgumentError if given fd is reserved by Ruby.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
been cleared by another thread while io_fillbuf() is waiting at
select(). a patch in [ruby-core:37197] by Hiroshi Shirosaki
<h.shirosaki AT gmail.com>. fixed#3840
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Fixed by Eric Wong. [ruby-core:36150]
(maygvl_copy_stream_wait_readwrite): removed.
(nogvl_copy_stream_sendfile): use nogvl_copy_stream_wait_write and
maygvl_copy_stream_wait_read instead of
maygvl_copy_stream_wait_readwrite.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
based on the patch by Eric Wong. [ruby-core:36156]
* vm_core.h (rb_thread_call_with_gvl): don't declare here.
* thread.c: include internal.h.
(rb_thread_execute_interrupts): new function.
* internal.h (rb_thread_execute_interrupts): declared.
(rb_thread_call_with_gvl): declared.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/ruby/test_io.rb: Test for File.write, File.binwrite.
* NEWS: News for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
DEFAULT_TEXTMODE in call of io_set_encoding(), and of write IO is
also set as it in call of io_new_instance() via rb_protect().
so, if DEFAULT_TEXTMODE is not 0, we should check the result of
extract_binmode() and avoid crush of default IO mode and the result.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
because boron chkbuild test result says, An old linux kernel ignore O_CLOEXEC
silently instead of return an error. It may lead to bring new security risk.
So, we have to be pending it until finish to implement proper fallback logic.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/ruby/test_io.rb (TestIO#test_o_cloexec): test for File::CLOEXEC.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread.c (select_single): select(2) based backend for rb_wait_for_single_fd().
* io.c (make_writeconv): use rb_wait_for_single_fd() instaed of
rb_thread_fd_select().
* io.c (rb_io_wait_readable): ditto.
* thread.c (rb_thread_wait_fd_rw): ditto.
* io.c (wait_readable): removed.
* thread.c (init_set_fd): new helper function.
* include/ruby/io.h (RB_WAITFD_IN, RB_WAITFD_PRI, RB_WAITFD_OUT):
new constant for rb_single_wait_fd().
The patch was written by Eric Wong. [Ruby 1.9 - Feature #4531]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31419 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
from copy_stream_body to rb_io_s_copy_stream. fds of passing
rb_fd_term() have to be guaranteed initialized.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
decorator according to open mode.
* transcode.c (rb_econv_prepare_options): new function, to prepare
econv options with newline flags.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
buffered, the buffers can be full or the file opened with
O_SYNC. IO#syswrite can also be used on blocking IOs
(pipe/socket) just like IO#write.
The patch is written by Eric Wong. [ruby-core:35554]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
close() may block for certain file types (NFS, SO_LINGER
sockets, inotify), so let other threads run. The patch was
created by Eric Wong [ruby-core:35555][Bug #4527]
* io.c (fptr_finalize): ditto.
* io.c (maygvl_fclose): new.
* io.c (nogvl_fclose): ditto.
* io.c (maygvl_close): ditto.
* io.c (nogvl_close): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31230 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
release GVL during calling kernel interface.
Suggested by Eric Wong. [ruby-core:35417][Bug #4463]
* test/ruby/test_io.rb (TestIO#test_fcntl_lock): add new test for
IO.fcntl().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
RSTRING_PTR() for function calls since it evaluates the argument
a couple of times.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
blocking region with GIL released, for fd.
* thread.c (rb_thread_fd_close): implement. [ruby-core:35203]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Therefore we should only check the result is -1 or not. [ruby-core:34062]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
also uses __syscall if available for *BSD on 64bit architecture.
[ruby-core:34062]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
in Windows. see [ruby-core:33460] and r29980. and, we have to
discuss how to do this one byte.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30280 b2dd03c8-39d4-4d8f-98ff-823fe69b080e