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
rb_thread_s_check_interrupt): added for
Thread.control_intgerrupt and Thread.check_interrupt.
See details on rdoc.
I'll make an ticket for this feature.
* test/ruby/test_thread.rb: add a test for Thread.control_intgerrupt.
* thread.c (rb_threadptr_raise): make a new exception object
even if argc is 0.
* thread.c (rb_thread_kill): kill thread immediately if target thread
is current thread.
* vm_core.h (RUBY_VM_CHECK_INTS_BLOCKING): added.
CHECK_INTS while/after blocking operation.
* vm_core.h (RUBY_VM_CHECK_INTS): require rb_thread_t ptr.
* cont.c (fiber_switch): use replaced RUBY_VM_CHECK_INTS().
* eval.c (ruby_cleanup): ditto.
* insns.def: ditto.
* process.c (rb_waitpid): ditto.
* vm_eval.c (vm_call0): ditto.
* vm_insnhelper.c (vm_call_method): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Async events such as an exception throwed by Thread#raise,
Thread#kill and thread termination (after main thread termination)
will be queued to th->async_errinfo_queue.
- clear: clear the queue.
- enque: enque err object into queue.
- deque: deque err object from queue.
- active_p: return 1 if the queue should be checked.
rb_thread_t#thrown_errinfo was removed.
* vm_core.h: add declarations of rb_threadptr_async_errinfo_*.
remove rb_thread_t#thrown_errinfo field and
add rb_thread_t#async_errinfo_queue (queue body: Array),
rb_thread_t#async_errinfo_queue_checked (flag),
rb_thread_t#async_errinfo_mask_stack(Array, not used yet).
* vm.c (rb_thread_mark): fix a mark function.
* cont.c (rb_fiber_start): enque an error.
* process.c (after_fork): clear async errinfo queue.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c (sysopen_func, rb_sysopen_internal): cast through VALUE to get
rid of warnings. fixup of r36355.
* process.c (rb_waitpid_blocking, rb_waitpid): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c (is_popen_fork): check if fork and raise NotImplementedError if
unavailable.
* io.c (rb_io_s_popen): allow environment variables hash and exec
options as flat parameters, not in an array arguments.
[Feature#6651] [EXPERIMENTAL]
* process.c (rb_execarg_extract_options): extract exec options, but no
exceptions on non-exec options and returns them as a Hash.
* process.c (rb_execarg_setenv): set environment variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36229 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (check_exec_fds): separate check_exec_fds_1() since
nonstatic initializer of an aggregate type is not allowed by C89.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
fields.
* process.c (EXEC_OPTION_NEW_PGROUP): removed.
(proc_spawn_cmd): take a struct rb_execarg argument.
use the new fields.
(rb_execarg_addopt): use the new fields.
(rb_spawn_process): follow the proc_spawn_cmd change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
fd_dup2_child fields.
* process.c (EXEC_OPTION_DUP2): removed.
(EXEC_OPTION_CLOSE): removed.
(EXEC_OPTION_OPEN): removed.
(EXEC_OPTION_DUP2_CHILD): removed.
(mark_exec_arg): mark the new fields.
(check_exec_redirect1): change condition for default option.
(check_exec_redirect): take a struct rb_execarg argument.
use the new fields.
(rb_execarg_addopt): follow the check_exec_redirect change.
(check_exec_fds): use the new fields.
(save_redirect_fd): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (EXEC_OPTION_ENV): removed.
(mark_exec_arg): mark env_modification field.
(rb_exec_fillarg): update the new field, instead of options array.
(rb_execarg_fixup): use the new field.
(save_env): ditto.
(rb_execarg_run_options): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (EXEC_OPTION_RLIMIT): removed.
(mark_exec_arg): mark rlimit_limits field.
(rb_execarg_addopt): update the new fields, instead of options array.
(run_exec_rlimit): use the new field.
(rb_execarg_run_options): clear sarg using MEMZERO. use the new
field.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (EXEC_OPTION_CHDIR): removed.
(mark_exec_arg): mark chdir_dir field.
(rb_execarg_addopt): update the new fields, instead of options array.
(rb_execarg_run_options): use the new fields.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
close_others_maxhint fields.
* process.c (EXEC_OPTION_CLOSE_OTHERS): removed.
(rb_execarg_addopt): update the new fields, instead of options array.
(check_exec_fds): take eargp as an argument. update the
close_others_maxhint field.
(rb_execarg_fixup): follow the argument change of check_exec_fds.
(rb_execarg_run_options): use the new fields.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
unsetenv_others_do fields.
* process.c (EXEC_OPTION_UNSETENV_OTHERS): removed.
(rb_execarg_addopt): update the new fields, instead of options array.
(rb_execarg_fixup): use the new fields.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (EXEC_OPTION_PGROUP): removed.
(rb_execarg_addopt): update the new fields, instead of options array.
(run_exec_pgroup): take a struct rb_execarg argument. refer the new
fields.
(rb_execarg_run_options): follow run_exec_pgroup change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (rb_exec_async_signal_safe): use a constant expression
instead of a macro.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (rb_spawn_internal): fix type of a local variable.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (rb_execarg_addopt): always make Fixnum, and ignore higher
bits in too large umask value.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (rb_execarg_run_options): do not call any methods in the
async-signal-safe function. mask has been checked with NUM2MODET()
already and converted with LONG2NUM().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (rb_exec_fillarg): get rid of SIZE_T_MAX which may need
more headers.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (rb_exec_fillarg): treat '=' only in the first word. if
the first word does not contain '=', it is the command name and
environment assignments cannot be anymore.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Mac OS X. cf. the comment in before_exec_non_async_signal_safe.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/pty/extconf.rb: modify $INCFLAGS to include internal.h
* ext/pty/pty.c: include internal.h.
(chfunc): don't call rb_thread_atfork_before_exec. use
rb_exec_async_signal_safe instead of rb_f_exec.
(establishShell): set up earg. use rb_fork_async_signal_safe
instead of rb_fork_err.
* internal.h (rb_exec_async_signal_safe): declared.
(rb_fork_async_signal_safe): declared.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
process before exec, for invoking a command.
(rb_exec_atfork): call rb_exec_async_signal_safe only.
(retry_fork): take chfunc_is_async_signal_safe argument. call
before_fork and after_fork only unless chfunc_is_async_signal_safe.
(send_child_error): take chfunc_is_async_signal_safe argument.
send an exception only unless chfunc_is_async_signal_safe.
(recv_child_error): take chfunc_is_async_signal_safe argument.
receive an exception only unless chfunc_is_async_signal_safe.
(rb_fork_internal): renamed from rb_fork_err and take
chfunc_is_async_signal_safe argument.
use rb_protect only unless chfunc_is_async_signal_safe.
(rb_fork_err): call rb_fork_internal with false as
chfunc_is_async_signal_safe.
(rb_fork_async_signal_safe): call rb_fork_internal with true as
chfunc_is_async_signal_safe.
(rb_spawn_process): call rb_fork_async_signal_safe instead of
rb_fork_err.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
enabled by default.
(rb_f_exec): don't need to set the option.
(rb_exec_arg_prepare): don't need to set the option. don't need
default_close_others argument.
(rb_spawn_internal): don't need to give default_close_others
argument for rb_exec_arg_prepare. don't need default_close_others
argument.
(rb_spawn_err): don't need to give default_close_others
argument for rb_spawn_internal.
(rb_spawn): don't need to give default_close_others
argument for rb_spawn_internal.
(rb_f_system): don't need to give default_close_others argument for
rb_spawn_internal.
(rb_f_spawn): don't need to give default_close_others argument for
rb_exec_arg_prepare.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
to close ep[0] and ep[1]. The catched exception is re-raised
immediately after that if status is not NULL.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (rb_fork_err): error state in the child process is prior
to exceptions in proc_syswait().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (rb_fork_err): determine status on errors.
* ext/pty/pty.c (establishShell): reraise exception if something
raised during sleep.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e