* process.c (check_exec_redirect_fd, check_exec_redirect),
(rb_execarg_addopt): get rid of inadvertent ID pindown.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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
* process.c (free_exec_arg): remove
(memsize_exec_arg): ptr is never NULL
(exec_arg_data_type): use RUBY_TYPED_DEFAULT_FREE
* variable.c (autoload_i_free): remove
(autoload_data_i_type): use RUBY_TYPED_DEFAULT_FREE
(autoload_memsize): ptr is never NULL
* vm_backtrace.c (location_free): remove
(location_mark): ptr is never NULL
(location_data_type): use RUBY_TYPED_DEFAULT_FREE
(backtrace_mark): ditto
(backtrace_free): ditto
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (Init_process): subclass Thread as Process::Waiter
(rb_detach_process): use Process::Waiter instead of singleton class
* test/ruby/test_process.rb (test_process_detach): new test
* inits.c (rb_call_inits): call Init_Thread before Init_process to
ensure Process::Waiter may be a subclass of Thread
Thanks to headius for reporting [Bug #10231]
Thanks to nobu for review of my initial patch.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (retry_fork_async_signal_safe): revert r47439 but
disable use of vfork on OS X instead, as it cause hang-up at
test_process.rb:test_deadlock_by_signal_at_forking with parallel
test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (retry_fork_async_signal_safe): vfork may not work
with pthread always even if fork works with it.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (rb_exec_without_timer_thread): add missing semicolon
to fix compilation error on OS X and Haiku.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (getresuid): Defined for AIX.
(getresgid): Ditto
AIX don't have getresuid/getresgid but getuidx/getgidx.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
vfork() is still faster than fork() especially when the parent
process uses big memory.
ruby -rbenchmark -e 'a = "a" * 1_000_000_000; puts Benchmark.measure { system("true") }'
fork: 0.000000 0.010000 0.010000 ( 0.014968)
vfork: 0.000000 0.000000 0.000000 ( 0.000912)
on Debian sid.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
retry_fork respect to rb_fork_async_signal_safe.
(retry_fork_ruby): Specialized version of retry_fork respect to
rb_fork_ruby.
(rb_fork_ruby): Removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (rlimit_resource_type, rlimit_resource_value): get rid
of function calls in RSTRING_PTR(), as it evaluates the argument
twice.
* re.c (match_backref_number): ditto.
* signal.c (esignal_init, rb_f_kill, trap_signm): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (open): use UTF-8 version function to support
non-ascii path properly. [ruby-core:63185] [Bug #9946]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (run_exec_open): use a local variable to get rid of
RARRAY_AREF() is evaluated multiple times by RSTRING_PTR().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (check_exec_redirect): use RB_TYPE_P instead of single
comparison of TYPE().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(OBJ2GID1): Defined even if getgrnam_r is not usable.
This fixes compilation error on Android.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (obj2uid, obj2gid): now getpwnam_r() and getgrnam_r()
may need larger buffers than sysconf values, so retry with
expanding the buffer when ERANGE is returned.
[ruby-core:61325] [Bug #9600]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45290 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (obj2uid, obj2gid): need capacity as buffer size, not
length.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45289 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (GETPW_R_SIZE_INIT, GETGR_R_SIZE_INIT): sysconf values
are not maximum sizes, but initial sizes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45288 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (OBJ2UID1, OBJ2GID1): separate from OBJ2UID and
OBJ2GID respectively, need given buffers.
* process.c (OBJ2UID, OBJ2GID): no longer need PREPARE_GETPWNAM
and PREPARE_GETGRNAM.
* process.c (obj2uid, obj2gid): use tmp buffer instead of alloca
to get rid of potential stack overflow.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
0001-process.c-avoid-EINTR-from-Process.spawn.patch written by
Eric Wong in [Bug #8770].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (send_child_error): retry write on EINTR to fix
occasional Errno::EINTR from Process.spawn.
* process.c (recv_child_error): retry read on EINTR to fix
occasional Errno::EINTR from Process.spawn.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
signal is sent to the parent process while Ruby is forking in IO.popen.
Patch by Scott Francis. Closes GH-513.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (rb_execarg_fixup): use RHASH_TBL_RAW and insert write
barriers where appropriate
* vm.c (kwmerge_i): use RHASH_TBL_RAW
* vm.c (HASH_ASET): use rb_hash_aset instead of calling directly into
st_insert
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44052 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (RB_BLOCK_CALL_FUNC_ARGLIST): for declaration
argument list of rb_block_call_func.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (Init_process): rename Struct::Tms as Process::Tms. keep
the former defined for the backward compatibility, for the time
being.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (rb_fork_internal): remove cloexec setting on pipes
created by rb_cloexec_pipe. patch by normalperson (Eric Wong) at
[ruby-core:56523]. [Bug #8769]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(rb_clock_gettime): Use get_mach_timebase_info.
(rb_clock_getres): Support MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (rb_clock_getres): move conditionally used variable to the
proper block.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (rb_intern): no symbol cache while initialization.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(gcd_timtick_int): Renamed from gcd_ul and make the arguments
timetick_giga_count_t.
(reduce_fraction): Make the arguments timetick_int_t.
(timetick2integer): Ditto.
(make_clock_result): Ditto.
(timetick2dblnum): Fix the return type.
(rb_clock_gettime): Use timetick_int_t.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42668 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (rb_clock_gettime): cast for tv_nsec explicitly to
suppress warnings by VC.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42657 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(rb_clock_gettime): times() based CLOCK_PROCESS_CPUTIME_ID emulation
is implemented.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42642 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This is accepted in the meeting:
https://bugs.ruby-lang.org/projects/ruby/wiki/DevelopersMeeting20130809
This method is accepted as a CRuby feature.
I.e. Other Ruby implementations don't need to implement it.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
with regard to the shell and OS. Patched by Steve Klabnik [Bug #8550]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (fork_daemon): kill the other threads all and abandon the
kept mutexes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add reference to spawn to fork
* add an example which runs ruby
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
RBASIC_CLASS(obj) macro which returns a class of `obj'.
This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
This function reveal interal (hidden) object by rb_obj_hide().
Note that do not change class before and after hiding.
Only permitted example is:
klass = RBASIC_CLASS(obj);
rb_obj_hide(obj);
....
rb_obj_reveal(obj, klass);
TODO: API design. rb_obj_reveal() should be replaced with others.
TODO: modify constified variables using cast may be harmful for
compiler's analysis and optimizaton.
Any idea to prohibt inserting RBasic::klass directly?
If rename RBasic::klass and force to use RBASIC_CLASS(obj),
then all codes such as `RBASIC(obj)->klass' will be
compilation error. Is it acceptable? (We have similar
experience at Ruby 1.9,
for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (proc_spawn_cmd_internal, proc_spawn_sh): spawn() with
P_NOWAIT returns process ID, so it must not be set as a status.
* process.c (rb_spawn_process): set failed status on error on
platforms using spawnv not only on Windows.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (rb_daemon): should not raise exceptions, since
proc_daemon() will deal with errors.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
directly without shell if the commandline is simple enough.
[ruby-core:50459] [Bug #7489]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
creating communication pipe logic into separate function.
* thread_pthread.c (setup_communication_pipe): new helper function.
* thread_pthread.c (set_nonblock): moves a definition before
setup_communication_pipe.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (RB_MAX_GROUPS): here.
* file.c (rb_group_member): use RB_MAX_GROUPS instead of
RUBY_GROUP_MAX. They are the same.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
_SC_GETGR_R_SIZE_MAX is available.
MirOS BSD (MirBSD 10 GENERIC#1382 i386) have getgrnam_r() but
no _SC_GETGR_R_SIZE_MAX.
(obj2uid): use getpwnam_r() only if getpwnam_r() and
_SC_GETPW_R_SIZE_MAX is available.
This is consistency for obj2gid.
MirOS BSD have neither getpwnam_r() nor _SC_GETPW_R_SIZE_MAX.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
from Thread.async_interrupt_timing to Thread.handle_interrupt,
from Thread.async_interrupted? to Thread.pending_interrupt?.
Also rename option from `defer' to `never'.
[ruby-core:51074] [ruby-trunk - Feature #6762]
* vm_core.c, thread.c: rename functions and data structure
`async_errinfo' to `pending_interrupt'.
* thread.c: add global variables sym_immediate, sym_on_blocking and
sym_never.
* cont.c, process.c, vm.c, signal.c: ditto.
* lib/sync.rb, lib/thread.rb: catch up this renaming.
* test/ruby/test_thread.rb: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Contributed from fumiyas (Fumiyasu SATOH). Thank you!
[Feature #6757] [ruby-dev:45977]
* configure.in: adds getsid check.
* test/ruby/test_process.rb (TestProcess#test_setsid): new test
for the above.
* NEWS: news for the above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
because if there is no allocated console at the moment Windows does
not automatically associate it for child process's standard handle.
this is adhoc workaround.
reported by Martin Thiede at [ruby-core:48542] [Bug #7239].
* io.c (rb_cloexec_dup2): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e