summaryrefslogtreecommitdiff
path: root/process.c
AgeCommit message (Collapse)Author
2017-11-14process.c: removed preserving_errnonobu
* process.c (try_with_sh, handle_fork_error): added argument for errno. * process.c (proc_exec_cmd, proc_exec_sh, exec_async_signal_safe): now return errno instead of -1. * process.c (rb_fork_ruby): merged retry_fork_ruby() and unified clean-up after fork regardless failure. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-06move rb_thread_t::interrupt_flag and maskko1
to rb_execution_context_t. * vm_core.h (rb_thread_t): move `rb_thread_t::interrupt_flag` and `rb_thread_t::interrupt_mask` to rb_execution_context_t. RUBY_VM_CHECK_INTS() accepts `ec` instead of `th`. * cont.c (rb_fiber_terminate): to propagate interrupt information, add new parameter `need_interrupt`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29`rb_ec_error_print()`.ko1
* eval_error.c (rb_threadptr_error_print): renamed to rb_ec_error_print() and it accepts `ec`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26replace `GET_THREAD()->ec` to `GET_EC()`.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26Use rb_execution_context_t instead of rb_thread_tko1
to represent execution context [Feature #14038] * vm_core.h (rb_thread_t): rb_thread_t::ec is now a pointer. There are many code using `th` to represent execution context (such as cfp, VM stack and so on). To access `ec`, they need to use `th->ec->...` (adding one indirection) so that we need to replace them by passing `ec` instead of `th`. * vm_core.h (GET_EC()): introduced to access current ec. Also remove `ruby_current_thread` global variable. * cont.c (rb_context_t): introduce rb_context_t::thread_ptr instead of rb_context_t::thread_value. * cont.c (ec_set_vm_stack): added to update vm_stack explicitly. * cont.c (ec_switch): added to switch ec explicitly. * cont.c (rb_fiber_close): added to terminate fibers explicitly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26common conversion functionsnobu
* array.c (rb_to_array_type): make public to share common code internally. * hash.c (rb_to_hash_type): make public to share common code internally. * symbol.c (rb_to_symbol_type): make public to share common code internally. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-23Drop to support NaCl platform.hsbt
Because NaCl and PNaCl are already sunset status. see https://bugs.chromium.org/p/chromium/issues/detail?id=239656#c160 configure.ac: Patch for this file was provided by @nobu. [Feature #14041][ruby-core:83497][fix GH-1726] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-11process.c: null byte at initgroupsnobu
* process.c (proc_initgroups): check null byte. patched by tommy (Masahiro Tomita) in [ruby-dev:50287]. [Bug #13995] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-20process: block/unblock signals around forknormal
As with forking for execve(2) in `spawn', we must block signals to ensure they are handled correctly in a freshly `fork'-ed child. * process.c (retry_fork_ruby): block/unblock signals around fork (rb_fork_ruby): re-enable signals in forked child * test/ruby/test_process.rb (test_forked_child_signal): new test [ruby-core:82883] [Bug #13916] Thanks to Russell Davis for the bug report and test case. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59975 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-19adjust indentnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-14process.c: null bytesnobu
* process.c (rlimit_type_by_sym): prohibit null bytes in key names. [ruby-core:82033] [Bug #13744] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59325 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-13process.c: handle dynamic :rlimit_* symbols in spawn execoptsnormal
* process.c (rb_execarg_addopt_rlimit): hoist out of rb_execarg_addopt (rlimit_type_by_sym): new wrapper for dynamic symbol (rb_execarg_addopt): check for dsym via rlimit_type_by_sym * test/ruby/test_process.rb (test_execopts_rlimit): check dsym w/o pindown Add extra check for bogus rlimit args, too. [ruby-core:82033] [Bug #13744] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-28move fields to ec.ko1
* vm_core.h (rb_thread.h): move errinfo and trace_arg to rb_execution_context_t. * cont.c (fiber_switch, rb_cont_call): do not restore "trace_arg" here. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-26move several fields from rb_thread_t to rb_execution_context_t.ko1
* vm_core.h (rb_thread_t): move several fields which are copied at cont.c to rb_execution_context_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-16removed ruby_error_printnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-31Improve performance of implicit type conversionwatson1978
To convert the object implicitly, it has had two parts in convert_type() which are 1. lookink up the method's id 2. calling the method Seems that strncmp() and strcmp() in convert_type() are slightly heavy to look up the method's id for type conversion. This patch will add and use internal APIs (rb_convert_type_with_id, rb_check_convert_type_with_id) to call the method without looking up the method's id when convert the object. Array#flatten -> 19 % up Array#+ -> 3 % up [ruby-dev:50024] [Bug #13341] [Fix GH-1537] ### Before Array#flatten 104.119k (± 1.1%) i/s - 525.690k in 5.049517s Array#+ 1.993M (± 1.8%) i/s - 10.010M in 5.024258s ### After Array#flatten 124.005k (± 1.0%) i/s - 624.240k in 5.034477s Array#+ 2.058M (± 4.8%) i/s - 10.302M in 5.019328s ### Test Code require 'benchmark/ips' class Foo def to_ary [1,2,3] end end Benchmark.ips do |x| ary = [] 100.times { |i| ary << i } array = [ary] x.report "Array#flatten" do |i| i.times { array.flatten } end x.report "Array#+" do |i| obj = Foo.new i.times { array + obj } end end git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-28process.c: Use getrusage(2) in Process.timesk0kubun
if getrusage(2) is available, to improve precision of Process.times and its user like lib/benchmark.rb. On macOS, since getrusage(2) has better precision than times(3), they are much improved like: * Before Process.times => #<struct Process::Tms utime=0.56, stime=0.35, cutime=0.04, cstime=0.03> puts Benchmark.measure { "a" * 1_000_000_000 } 0.340000 0.310000 0.650000 ( 0.674025) * After Process.times => #<struct Process::Tms utime=0.561899, stime=0.35076, cutime=0.046483, cstime=0.038929> puts Benchmark.measure { "a" * 1_000_000_000 } 0.343223 0.310037 0.653260 ( 0.674025) On Linux, since struct rusage from getrusage(2) is used instead of struct tms from times(2), they are slightly improved like: * Before Process.times => #<struct Process::Tms utime=0.43, stime=0.11, cutime=0.0, cstime=0.0> puts Benchmark.measure { "a" * 1_000_000_000 } 0.120000 0.040000 0.170000 ( 0.171621) * After Process.times => #<struct Process::Tms utime=0.432, stime=0.116, cutime=0.0, cstime=0.0> puts Benchmark.measure { "a" * 1_000_000_000 } 0.124000 0.048000 0.172000 ( 0.171621) [ruby-dev:49471] [Feature #11952] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-11process.c: fix error checknobu
* process.c (obj2uid, obj2gid): check the error number returned by `getpwnam_r()` and `getgrnam_r()`, instead of `errno`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-10.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-10process.c: temporary string for buffernobu
* process.c (obj2uid, obj2gid): use temporary string as the buffer instead of `rb_alloc_tmp_buffer`, which is `NODE_ALLOCA` since r51492. [ruby-core:81084] [Bug #13554] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-29Add documents on Process::CLOCK_* constantssorah
* process.c: Add documents on Process::CLOCK_* constants. Patch by Sunao Komuro <sunao-komuro@cookpad.com>. Closes [GH-1567] [Bug #13386] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-06use HAVE_BUILTIN___BUILTIN_MUL_OVERFLOWshyouhei
We already check for __builtin_mul_overflow in configure but never actually referred it before. Why not call it if available, because that should render supposedly-optimial assembly outputs. Optionally if __builtin_mul_overflow_p is available, which is the case for recent GCC, use that to detect fixnum overflow. This is much faster than the previous. On my machine generated assembly of numeric.c:int_pow reduces from 480 to 448 bytes, according to nm(1). Also on my machine, following script boosts from 7.819 to 6.929 sec. time ./miniruby -e 'i=0; while i < 30_000_000 do i += 1; 7 ** 23; end' Signed-off-by: Urabe, Shyouhei <shyouhei@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-06process.c: PATH env in spawnnobu
* process.c (rb_exec_fillarg): honor the given path environment variable. [ruby-core:53103] [Bug #8004] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-26[DOC] replace Fixnum with Integer [ci skip]nobu
* numeric.c: [DOC] update document for Integer class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-14process.c: use uaspawnnobu
* process.c (proc_exec_cmd): use UTF-8 version aspawn. [ruby-dev:49838] [Bug #12841] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-24fid typos [ci skip]nobu
* fix typos, "a" before "Integer" to "an". [Fix GH-1438] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-21* process.c (InitVM_process): Support CLOCK_MONOTONIC_RAW_APPROX,naruse
CLOCK_UPTIME_RAW, and CLOCK_UPTIME_RAW_APPROX which are introduced by macOS 10.12. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-08replace fixnum by integer in documents.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-28* vm_core.h: revisit the structure of frame, block and env.ko1
[Bug #12628] This patch introduce many changes. * Introduce concept of "Block Handler (BH)" to represent passed blocks. * move rb_control_frame_t::flag to ep[0] (as a special local variable). This flags represents not only frame type, but also env flags such as escaped. * rename `rb_block_t` to `struct rb_block`. * Make Proc, Binding and RubyVM::Env objects wb-protected. Check [Bug #12628] for more details. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-04fix typonaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-04* process.c: define sig_t if not exist.naruse
at least Solaris 10 and 11 doesn't have sig_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-02process.c (disable_child_handler_fork_child): simplifynormal
signal(2) is portable for SIG_DFL and SIG_IGN, so we do not need the extra code for sigaction(2). Also, execve will reset all signal handlers to default anyways, so there is little sense in preserving old signal handler besides SIG_IGN. Hopefully this makes the code easier-to-understand and maintain. * process.c (disable_child_handler_fork_child): simplify [ruby-core:75781] [Misc #12439] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-27process.c: [DOC] Process.abort [ci skip]nobu
* process.c (rb_f_abort): [DOC] Process.abort is a singleton method of Process, but not an instance method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-20fix build on no-fork-spawnv platformsnobu
* process.c (rb_execarg_commandline): build command line string from argument vector in rb_execarg. [ruby-core:75611] [Bug #12398] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55091 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-08* configure.in: check function attirbute const and pure,naruse
and define CONSTFUNC and PUREFUNC if available. Note that I don't add those options as default because it still shows many false-positive (it seems not to consider longjmp). * vm_eval.c (stack_check): get rb_thread_t* as an argument to avoid duplicate call of GET_THREAD(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-08* configure.in: add -Wsuggest-attribute=noreturn and suppress warnings.naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-06process.c: argument types over conversionnobu
* process.c (rb_exec_getargs): honor the expected argument types over the conversion method. the basic language functionality should be robust. [ruby-core:75388] [Bug #12355] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-02process.c (disable_child_handler_fork_child): initialize handler for SIGPIPEnormal
This only happens on the !POSIX_SIGNAL case; but one may test with the following: --- a/process.c +++ b/process.c @@ -3479,6 +3479,7 @@ disable_child_handler_fork_parent(struct child_handler_disabler_state *old) #endif } +#undef POSIX_SIGNAL /* This function should be async-signal-safe. Actually it is. */ static int disable_child_handler_fork_child(struct child_handler_disabler_state *old, char *errmsg, size_t errmsg_buflen) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-14process.c: prefer rb_check_aritynobu
* process.c: use rb_check_arity instead of rb_scan_args for simple optional arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-27* process.c (rb_execarg_parent_start1): need to convert the encoding tousa
ospath's one. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-27* process.c (rb_execarg_addopt): need to convert to ospath.usa
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-27* process.c: use rb_w32_uchdir() instead of plain chdir() on Windows.usa
reported by naruse via twitter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-23prefer rb_syserr_failnobu
* file.c, io.c, util.c: prefer rb_syserr_fail with saved errno over setting errno then call rb_sys_fail, not to be clobbered potentially and to reduce thread local errno accesses. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-14* enum.c: fix a typo in documentation.hsbt
[ci skip][fix GH-1140] Patch by @jutaz * io.c: ditto. * iseq.c: ditto. * numeric.c: ditto. * process.c: ditto. * string.c: ditto. * vm_trace.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-04process.c: fix rdoc of Process.getsid [ci skip]nobu
* process.c (proc_getsid): [DOC] Fix double word 'for' and typo. [Fix GH-1080] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-18* ChangeLog: Good-bye OS/2.kosaki
* common.mk: ditto. * configure.in: ditto. * dln_find.c: ditto. * ext/Setup.emx: ditto. * ext/extmk.rb: ditto. * ext/socket/extconf.rb: ditto. * ext/zlib/extconf.rb: ditto. * file.c: ditto. * include/ruby/defines.h: ditto. * io.c: ditto. * lib/mkmf.rb: ditto. * missing/os2.c: ditto. * process.c: ditto. * ruby.c: ditto. * NEWS: announce OS/2 is no longer supported. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-12process.c: do not inherit saved fdsnobu
* process.c (save_redirect_fd): make saved FDs close-on-exec not to be inherited. * process.c (run_exec_dup2): restore close-on-exec flags too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51832 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-10Clarify spawn pgroup documentation [ci skip]nobu
* process.c (rb_f_spawn): Be more specific regarding "other values" by having "non-zero positive integers" Add nil, the default value, as a possible value and what it means. Try to use more consistent language. [Fix GH-1008] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-08process.c: keep GVL if WNOHANGnobu
* process.c (rb_waitpid): do not release GVL when WNOHANG is set, it should return immediately without blocking. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-08process.c: retry loopnobu
* process.c (rb_waitpid): refactor retry loop by interrupt. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e