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

1147 Коммитов

Автор SHA1 Сообщение Дата
usa 44cff77b95 * io.c (rb_cloexec_open): set O_NOINHERIT instead of O_CLOEXEC if it is
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
2011-11-18 04:06:01 +00:00
usa bbe004c1e4 * io.c (argf_next_argv): wrong timing of setting ecflags.
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
2011-11-16 02:36:08 +00:00
akr 3d25acdccc * io.c, thread.c, ext/pty/pty.c, ext/fiddle/closure.c: use
__linux__ macro for consistency.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-15 11:09:47 +00:00
nobu 80c32b2330 * io.c (do_ioctl, ioctl_narg_len, setup_narg, rb_ioctl): use
ioctl_req_t.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 08:26:13 +00:00
nobu 9998578951 * ChangeLog, io.c: whitespace-cleanup.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 07:49:48 +00:00
kosaki 33817fbc29 * io.c (fcntl_narg_len): introduce narg calculation for fcntl instead
of hard coded 256.
* io.c (setup_narg): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 02:33:58 +00:00
kosaki 791f5449c1 * io.c (ioctl_narg_len): Linux doesn't have IOCPARM_LEN macro, but
has _IOC_SIZE. support it.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 02:29:37 +00:00
kosaki b3027d5929 * io.c (rb_ioctl): don't expose our sanity check value to ruby script.
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
2011-11-12 02:27:51 +00:00
kosaki 7e2f0491ce * io.c (ioctl_req_t): Type of req argument of ioctl() depend on platform.
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
2011-11-12 02:24:51 +00:00
kosaki fc7bb927a2 * io.c (struct io_cntl_arg): remove io_p member.
* io.c (nogvl_fcntl, do_fcntl, rb_fcntl): separated from ioctl functions.
* io.c (nogvl_io_cntl): remove fcntl depended logic.
* io.c (io_cntl): ditto.
* io.c (rb_io_ctl): ditto.
* io.c (rb_io_ioctl): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 02:17:41 +00:00
kosaki f13d10a0af * io.c (setup_narg): fix off by one bug.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 02:12:19 +00:00
kosaki eec252e2e5 * io.c (+setup_narg): factor out length calculation logic.
* io.c (rb_io_ctl): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 02:09:56 +00:00
kosaki 9d16ad639f * io.c (+ioctl_narg_len) new helper function.
* 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
2011-11-12 02:06:23 +00:00
kosaki 0d746627af * io.c (pipe_open): Remove fflush(stdin). it's no effect.
Pointed out by Ikegami Daisuke <ikegami.da@gmail.com>.
  Thank you.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-11 03:41:13 +00:00
nobu 1393e55d09 * io.c (rb_update_max_fd): fstat(2) can fail with other than
EBADF.  [ruby-dev:44837] [Backport #4339].  Cf.
  http://pubs.opengroup.org/onlinepubs/9699919799/functions/fstat.html

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-09 14:20:27 +00:00
nobu 42b4255d08 * io.c (rb_sysopen): max fd is updated in rb_sysopen_internal()
already.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-09 13:54:33 +00:00
usa 53881a8c6d * io.c (io_fwrite): call rb_w32_write_console() only if FMODE_TTY is
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
2011-11-08 05:52:32 +00:00
akr bd3b3c1b51 update doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-07 21:01:40 +00:00
usa add77a592b * include/ruby/encoding.h (ECONV_NEWLINE_DECORATOR_READ_MASK,
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
2011-11-07 17:48:11 +00:00
usa 66595f3894 * io.c (io_fflush): remove fsync().
* 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
2011-11-07 11:08:39 +00:00
akr 987c03a387 * io.c (rb_close_before_exec): use F_MAXFD if available.
F_MAXFD is available on NetBSD since NetBSD 2.0.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-07 10:44:02 +00:00
akr 333c847f19 * io.c (rb_cloexec_fcntl_dupfd): don't clear try_dupfd_cloexec if
fcntl(F_DUPFD) failed as fcntl(F_DUPFD_CLOEXEC).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-05 10:13:00 +00:00
nobu 413f24d3b0 * whitespace cleanup.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-04 07:19:23 +00:00
usa a3ce319639 * io.c (make_writeconv): fixed typo of previous commit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-03 19:06:43 +00:00
usa 102ec1171d * io.c (make_writeconv): fixed typo of previous commit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-03 18:45:41 +00:00
usa 932d63efe0 * io.c (make_writeconv): unversal_newline converter is for reading.
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
2011-11-03 16:59:53 +00:00
naruse f0bd639693 * io.c (rb_cloexec_pipe): remove workaround of r33587.
The bug of NetBSD is fixed on Mon Oct 31 21:31:29 UTC 2011.
  http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=45545

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-01 12:43:47 +00:00
akr 809006f407 * io.c (rb_io_reopen): call rb_fd_fix_cloexec instead of
rb_maygvl_fd_fix_cloexec.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33605 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-01 10:49:40 +00:00
akr 89a1258110 * io.c (rb_io_reopen): call rb_maygvl_fd_fix_cloexec after freopen().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-01 10:01:01 +00:00
naruse f926980902 * io.c (nogvl_io_cntl): rb_cloexec_fcntl_dupfd's 2nd argument is int.
* process.c (move_fds_to_avoid_crash): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-01 05:56:51 +00:00
akr c16f98ab0a * io.c (rb_maygvl_fd_fix_cloexec): renamed from fd_set_cloexec.
* internal.h (rb_maygvl_fd_fix_cloexec): declared.

* ext/socket/init.c (cloexec_accept): use rb_maygvl_fd_fix_cloexec.
  (rsock_s_accept_nonblock): use rb_update_max_fd.
  (rsock_s_accept): use rb_update_max_fd.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-01 03:04:03 +00:00
akr 24176a8d5d add comment.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-31 23:24:25 +00:00
naruse 6a96646de2 Fix previous commit (r33586).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-31 13:50:32 +00:00
naruse ca6311b0b5 * io.c (rb_cloexec_pipe): NetBSD 6.0 will support pipe2(2),
but its return value is -1 or larger than 0.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-31 13:21:03 +00:00
akr 1a70dfe6f4 * include/ruby/intern.h (rb_fd_fix_cloexec): renamed from
rb_fd_set_cloexec.

* io.c: follow the above renaming.

* 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@33585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-31 12:49:16 +00:00
akr 687c41dc4d * io.c (fd_set_cloexec): clear CLOEXEC flag for standard file
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
2011-10-31 11:17:15 +00:00
akr da5ae5544d * io.c (rb_cloexec_dup2): check oldfd == newfd at first.
pointed by KOSAKI Motohiro.  [ruby-dev:44713]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-31 03:07:26 +00:00
usa bdc85361e4 * io.c (rb_cloexec_fcntl_dupfd): this function needs F_DUPFD.
* 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
2011-10-31 01:52:21 +00:00
akr 5c19f07700 * include/ruby/intern.h (rb_cloexec_fcntl_dupfd): declared.
* io.c (rb_cloexec_fcntl_dupfd): new function.
  (nogvl_io_cntl): use rb_cloexec_fcntl_dupfd.

* process.c (move_fds_to_avoid_crash): use rb_cloexec_fcntl_dupfd.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-30 15:17:27 +00:00
akr e7f8c03818 * configure.in: check pipe2.
* io.c (rb_cloexec_pipe): use pipe2 if available.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33574 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-30 13:48:35 +00:00
akr 0d2a92e0b3 * include/ruby/intern.h (rb_cloexec_pipe): declared.
* io.c (rb_cloexec_pipe): new function.
  (rb_pipe): use rb_cloexec_pipe.

* thread_pthread.c (rb_thread_create_timer_thread): use
  rb_cloexec_pipe.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-30 12:13:05 +00:00
akr 6e0ed044b6 * io.c (rb_cloexec_dup): refine control flow.
(rb_cloexec_dup2): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-30 11:07:09 +00:00
nobu 54816d10eb * io.c (rb_cloexec_dup, rb_cloexec_dup2): CLOEXEC has been set if
dup3 succeeded.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-30 01:47:23 +00:00
akr f0b021c0ce * io.c (rb_cloexec_dup): don't allocate standard file descriptors.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-30 01:02:46 +00:00
akr e745a03cfa * io.c (rb_cloexec_dup2): don't set CLOEXEC for standard file
descriptors.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-29 23:30:34 +00:00
akr cb9f3040d7 * configure.in: check dup3.
* io.c (rb_cloexec_dup2): use dup3 if available.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-29 22:48:41 +00:00
akr 0a9cb21e62 * include/ruby/intern.h (rb_cloexec_dup2): declared.
* io.c (rb_cloexec_dup2): new function.
  (io_reopen): use rb_cloexec_dup2.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-29 13:11:01 +00:00
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