Граф коммитов

1100 Коммитов

Автор SHA1 Сообщение Дата
akr 54d7e82613 * io.c (rb_cloexec_dup): use F_DUPFD_CLOEXEC if available.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-29 11:59:46 +00:00
akr a9648d1e58 add a comment.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33554 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-29 11:58:30 +00:00
akr 4ae2b92576 * include/ruby/intern.h (rb_cloexec_dup): declared.
* io.c (rb_cloexec_dup): new function.
  (ruby_dup): use rb_cloexec_dup.

* ext/pty/pty.c (pty_getpty): use rb_cloexec_dup.
  
* ext/openssl/ossl_bio.c (ossl_obj2bio): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-29 11:02:32 +00:00
akr baa2d74dae * io.c (rb_cloexec_open): use O_CLOEXEC if available.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-29 05:27:32 +00:00
akr 3ae3cd741d * include/ruby/intern.h (rb_cloexec_open): declared.
* 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
2011-10-29 02:33:28 +00:00
akr b317a4cd28 * io.c: use "__sun" instead of "sun" to detect SunOS.
* dln.c: ditto.

* cont.c: ditto.

* ext/sdbm/_sdbm.c: ditto.

[ruby-dev:44693]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-24 13:49:58 +00:00
akr a28fe36c89 * io.c (copy_stream_fallback_body): check nil for EOF of read method.
patch by Eric Wong.  [ruby-core:39134] [Bug #5237]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-23 23:19:14 +00:00
akr e7ff29581b * io.c (rb_fd_set_cloexec): set close-on-exec flag only if F_GETFD is
defined.  reported by Luis Lavena.  [ruby-core:40281] [Bug #5470]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-22 23:03:02 +00:00
akr b574a4d4a1 * include/ruby/intern.h (rb_fd_set_cloexec): declared.
* io.c (rb_fd_set_cloexec): new function.
  (ruby_dup): call rb_fd_set_cloexec to set close-on-exec flag.
  (rb_sysopen_internal): ditto.
  (rb_pipe): ditto.
  (io_reopen): ditto.
  (io_cntl): ditto.

* process.c (rb_f_exec): change the default :close_others option to
  true.
  (rb_f_system): ditto.
  (move_fds_to_avoid_crash): call rb_fd_set_cloexec to set
  close-on-exec flag.
  (ruby_setsid): ditto.
  (rb_daemon): ditto.

* thread_pthread.c (rb_thread_create_timer_thread): call
  rb_fd_set_cloexec to set close-on-exec flag.

* ruby.c (load_file_internal): ditto.

* file.c (rb_file_s_truncate): ditto.
  (file_load_ok): ditto.

* random.c (fill_random_seed): ditto.

* ext/pty/pty.c (chfunc): ditto.
  (get_device_once): ditto.

* ext/openssl/ossl_bio.c (ossl_obj2bio): ditto.

* ext/socket/init.c (rsock_socket): ditto.
  (rsock_s_accept_nonblock): ditto.
  (rsock_s_accept): ditto.

* ext/socket/socket.c (rsock_sock_s_socketpair): ditto.

* ext/socket/ancdata.c (discard_cmsg): ditto.
  (make_io_for_unix_rights): ditto.

* ext/socket/unixsocket.c (unix_recv_io): ditto.

* ext/io/console/console.c (console_dev): ditto.

[ruby-core:38140] [Feature #5041]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-22 09:58:15 +00:00
ktsj 02e4428ec5 * io.c: fix documentation of ARGF.lineno=.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33375 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-02 01:56:51 +00:00
nobu 8e6e8e6288 * use RB_TYPE_P which is optimized for constant types, instead of
comparison with TYPE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-29 11:07:45 +00:00
matz 1796817e46 * io.c (Init_IO): update BINARY comment. it should not change the
encoding of the result to ASCII-8BIT.  [ruby-talk:387719]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-12 20:38:17 +00:00
nobu 74f724de1a * io.c (argf_next_argv): open in default text mode.
[ruby-core:39234] [Bug #5268]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-03 14:52:18 +00:00
nobu 7dc7da3d86 * io.c (validate_enc_binmode, prep_stdio): default to text mode on
dosish platforms.  [ruby-core:38822] [Bug #5164]
* transcode.c (rb_econv_prepare_options): keep default ecflags
  unchanged if no options.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-02 12:11:17 +00:00
usa f9e9eee677 * util.c, include/ruby/util.h (ruby_add_suffix): remove the function.
[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
2011-08-03 07:10:56 +00:00
nobu f46cff647e * io.c (rb_pipe): pipe on cygwin can succeed half but fail
half.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-31 09:59:01 +00:00
naruse 4ac69a57b5 * io.c (rb_io_each_byte): remove unused variable e.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-30 16:31:36 +00:00
nobu 321346cfa5 * io.c (rb_io_each_byte): rbuf can be refreshed during yield.
[Bug #5119]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-30 14:14:46 +00:00
akr 2bcd502a71 * io.c (rb_update_max_fd): validate fd.
* ext/socket/rubysocket.h (rsock_discard_cmsg_resource): add
  msg_peek_p argument for the declaration.

* ext/socket/ancdata.c (discard_cmsg): add msg_peek_p argument.
  assume FreeBSD, NetBSD and MacOS X doesn't generate passed fd
  when MSG_PEEK. 
  (rsock_discard_cmsg_resource): add msg_peek_p argument.
  (bsock_recvmsg_internal): call rsock_discard_cmsg_resource with
  msg_peek_p argument.

* ext/socket/unixsocket.c (unix_recv_io): call
  rsock_discard_cmsg_resource with msg_peek_p argument.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-23 08:13:37 +00:00
kazu 55b0c9fb6c * io.c (rb_update_max_fd): remove parentheses. they are not in macro.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-20 15:00:00 +00:00
akr b41ccc4a9c * include/ruby/intern.h (rb_update_max_fd): declaration moved from
internal.h.

* file.c: ditto.

* io.c: call rb_update_max_fd for each new fds.

* process.c: ditto.

* random.c: ditto.

* ruby.c: ditto.

* ext/io/console/console.c: ditto.

* ext/openssl/ossl_bio.c: ditto.

* ext/pty/pty.c: ditto.

* ext/socket/init.c: ditto.

* ext/socket/socket.c: ditto.

* ext/socket/ancdata.c: ditto.

* ext/socket/unixsocket.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-20 13:26:10 +00:00
akr b1c03685bc * io.c (UPDATE_MAXFD): removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-19 07:27:26 +00:00
akr 2c7576a021 * io.c (rb_update_max_fd): new function.
* internal.h (rb_update_max_fd): declare rb_update_max_fd.

* thread_pthread.c (rb_thread_create_timer_thread): update max fd when
  timer thread pipe is created.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-19 07:10:19 +00:00
usa f15d0deaaf * win32/win32.c, include/ruby/win32.h (rb_w32_io_cancelable_p): renamed
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
2011-07-15 05:33:45 +00:00
drbrain 0c3833ec5a * io.c: Note that methods other than IO#gets may increase IO#lineno.
[Ruby 1.9 - Bug #4902]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-09 00:21:44 +00:00
nobu dc3697f62f * io.c (rb_io_close): close(2) on a fd which is being read by
another thread causes deadlock on Mac OS X 10.5

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-08 23:37:08 +00:00
ko1 eb35bb0b35 * include/ruby/intern.h, thread_pthread.c (rb_reserved_fd_p,
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
2011-07-03 21:56:59 +00:00
drbrain 926301969f * math.c: Attach documentation for Math.
* object.c:  Document NIL, TRUE, FALSE.
	* io.c:  Improve grammar in ARGF comment.  Document STDIN/OUT/ERR.
	  Document ARGF global constant.
	* lib/rake:  Hide deprecated toplevel constants from RDoc (import from
	  rake trunk).
	* lib/thwait.rb:  Document ThWait.
	* lib/mathn.rb:  Hide Math redefinition from RDoc
	* lib/sync.rb:  Add a basic comment for Sync_m, Synchronizer_m, Sync,
	  Synchronizer.
	* parse.y:  Document SCRIPT_LINES__.
	* hash.c:  Document ENV class and global constant.
	* vm.c:  Document TOPLEVEL_BINDING.
	* version.c:  Document RUBY_* constants.
	* ruby.c:  Document DATA and ARGV.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32281 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-29 03:09:34 +00:00
nobu 6effaa9a13 * io.c (fill_cbuf): finish reading at EOF, and the readconv has
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
2011-06-18 15:00:00 +00:00
akr 8192693ccf * io.c: supress warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-18 02:10:09 +00:00
akr e7996eb3cc * internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.

* iseq.h: declare rb_iseq_t dependent internal functions here.

* vm_core.h: declare rb_thread_t dependent internal functions here.

* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
  enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
  iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
  proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
  thread.c, time.c, transcode.c, variable.c, vm.c,
  tool/compile_prelude.rb: don't declare internal functions declared
  in above headers.  include above headers if required.

  Note that rb_thread_mark() was declared as
  void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
  void rb_thread_mark(void *ptr) in vm.c.  Now it is declared as
  the later in internal.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 22:43:38 +00:00
drbrain 2adddf4c2b * io.c: Improve documentation of IO and File open and new.
Patch by Roger Pack.  [Ruby 1.9 - Bug #4790]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-16 23:50:30 +00:00
akr 60e078c860 * io.c: use select() appropriately for sendfile().
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
2011-06-12 02:18:51 +00:00
nobu 34b19050b3 * io.c (io_getc): should be 7bit if ascii. fixes #4557
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-11 09:02:11 +00:00
akr 87f025da25 * io.c: fix IO.copy_stream interrupt handling.
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
2011-06-09 15:02:46 +00:00
usa 19c78f9b9b * io.c (io_fflush): windows -- call fsync() only when the FD is tied to
file, because if the FD is pipe, it blocks.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-03 10:59:37 +00:00
usa fd8010fc0a * io.c (rb_io_s_write, rb_io_s_binwrite): return!!!
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-02 11:06:40 +00:00
sorah 7b3948f055 * io.c: Add File.write, File.binwrite. [Feature #1081] [ruby-core:21701]
* 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
2011-06-02 07:30:11 +00:00
usa 2b0363df5d * io.c (io_flush, rb_io_flush): need to fsync() when ruby calls internal
flush. [ruby-core:36670] [Bug #4813]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31901 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-02 03:35:40 +00:00
ryan 38de163f1e doco: p outputs newline regardless of record separator
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-01 00:48:09 +00:00
nobu fcc86b0f4c * io.c (io_encoding_set): should honor already set ecflags since it
might be set by mode option.  fixed #4804

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-31 16:15:15 +00:00
nobu a010ea9a45 no space inside parens
* io.c: remove spaces before closing parens.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-31 15:05:09 +00:00
usa da1db8b454 * io.c (rb_io_s_pipe): potential bug. the mode of read IO is set as
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
2011-05-31 05:21:36 +00:00
naruse 9efb5a9d6a * io.c (fill_cbuf): return MORE_CHAR_SUSPENDED when cbuf is not empty.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-27 18:06:42 +00:00
kosaki 78271e8c72 * io.c (fill_cbuf): Fix test-all crash.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-27 17:09:27 +00:00
nobu b5bc09d234 * io.c (validate_enc_binmode): do not clear textmode flag if
default.  fixed #4732

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-27 13:45:12 +00:00
nobu 9909c67583 * io.c (fill_cbuf): finish reading at EOF.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-27 13:38:56 +00:00
kosaki 67cf354b46 * io.c (rb_io_extract_modeenc): accept combination hash and
File::Constants. (eg. File.open('yo', :mode => File::WRONLY))
  [Feature #4742][ruby-core:36338]
* test/ruby/test_io.rb (TestIO#test_open_mode): new test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-21 13:20:43 +00:00
kosaki 898374126e revert O_CLOEXEC patch series completely.
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
2011-05-19 12:18:41 +00:00
nobu 3a47cf3395 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-15 11:55:52 +00:00