summaryrefslogtreecommitdiff
path: root/process.c
AgeCommit message (Collapse)Author
2019-09-05Add version that FreeBSD supports `CLOCK_PROCESS_CPUTIME_ID` [ci skip]yuuji.yaginuma
Seems FreeBSD already supported `CLOCK_PROCESS_CPUTIME_ID`. That added by https://reviews.freebsd.org/rS239347 and the doc was updated by https://reviews.freebsd.org/rS315694. I confirmed `CLOCK_PROCESS_CPUTIME_ID` constant exists in 9.3.0 branch. https://github.com/freebsd/freebsd/blob/release/9.3.0/sys/sys/time.h#L269 Notes: Merged: https://github.com/ruby/ruby/pull/2429
2019-08-29move docs around [ci skip]卜部昌平
To properly generate documents.
2019-08-29drop-in type check for rb_define_global_function卜部昌平
We can check the function pointer passed to rb_define_global_function like we do so in rb_define_method. It turns out that almost anybody is misunderstanding the API.
2019-08-29drop-in type check for rb_define_module_function卜部昌平
We can check the function pointer passed to rb_define_module_function like how we do so in rb_define_method. The difference is that this changeset reveales lots of atiry mismatches.
2019-08-27delete `$` sign from C identifiers卜部昌平
They lack portability. See also https://travis-ci.org/shyouhei/ruby/jobs/577164015
2019-08-27rb_define_hooked_variable now free from ANYARGS卜部昌平
After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit uses rb_gvar_getter_t / rb_gvar_setter_t for rb_define_hooked_variable / rb_define_virtual_variable which revealed lots of function prototype inconsistencies. Some of them were literally decades old, going back to dda5dc00cff334cac373096d444a0fd59e716124.
2019-08-26uid_t and gid_t are narrower than VALUE.卜部昌平
Often uid / gid are 16 bit or 32 bit integers, while VALUE are 32 to 64 bits. They tend to differ in size. Because rb_ensure expects its callbacks to take VALUE arguments, narrowing must be done by hand, otherwise data corruption can happen depending on machine ABI.
2019-08-26Suppress a "clobbered" warningNobuyoshi Nakada
2019-07-16nil as the default of optional parametersNobuyoshi Nakada
2019-07-16nil as the default of optional parametersNobuyoshi Nakada
2019-07-16Moved the check for `exception` to rb_execarg_addoptNobuyoshi Nakada
Check for `exception` option in rb_execarg_addopt, as well as other options. And then raise a particular ArgumentError if it is not allowed.
2019-07-15process.c (p_sys_setregid, p_sys_setresgid): remove unused tmp bufferYusuke Endoh
To suppress Coverity Scan warning
2019-03-30process.c: [DOC] remove extra quotes [ci skip]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67386 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-29process.c: [DOC] fix markups [ci skip]nobu
* process.c (rb_f_spawn): fix markups as rdoc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-29process.c: [DOC] fix markups [ci skip]nobu
* process.c (rb_clock_getres): fix code markups, as `+` can not include parentheses. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-28[DOC] fix markups [ci skip]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-09new constant: Process::CLOCK_TAI.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-20process.c: [DOC] small improvementsstomar
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-10mjit.c: use boolean type for boolean variablesk0kubun
and functions to clarify the intention and make sure it's not used in a surprising way (like using 2, 3, ... other than 0, 1 even while it seems to be a boolean). This is a retry of r66775. It included some typos... git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-10Revert "mjit.c: use boolean type for boolean variables"k0kubun
This reverts commit bb1a1aeab0f2a5fe437c89b841a887ba56653453. We hit something on ci.rvm.jp, reverting until investigation is done. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-10mjit.c: use boolean type for boolean variablesk0kubun
and functions to clarify the intention and make sure it's not used in a surprising way (like using 2, 3, ... other than 0, 1 even while it seems to be a boolean). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-29process.c: document system(..., exception: true) [ci skip]k0kubun
From: Victor Shepelev <zverok.offline@gmail.com> [Bug #15480] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-22Use idExceptionnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-04process.c (retry_fork_async_signal_safe): fix -Wclobberednobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-03process.c (retry_fork_async_signal_safe): fix -Wclobbered on i686normal
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-03process.c: fix ETXTBUSY from MJIT compiler processnormal
This affects test/ruby/test_process.rb (test_execopt_env_path). Since MJIT uses vfork+execve in a separate thread, there can be small window in-between vfork and execve where tmp_script.cmd is held open by the vforked child. vfork only pauses the MJIT thread, not any Ruby Threads, so our call to Process.spawn will hit ETXTBUSY in that window unless we fork. main thread | MJIT thread ---------------------------------------------------- fd = open(tmp) | | | vfork for CC | CC running write | | --------------- fchmod | | sees "fd" here close(fd) | | Process.spawn called | | vfork (spawn)| (new process) | | | execve => TXTBUSY | | | | | execve (FD_CLOEXEC on fd) | | vfork returns | Holding the waitpid_lock whenever we intend to spawn a process prevents the MJIT thread from spawning a process while we are spawning in Ruby-land. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-03process.c (rb_execarg_init): mark as staticnormal
io.c has not used it since r36229, and we can re-export it if we need it at another time. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-03process.c (rb_f_system): cleanup to use rb_execarg_getnormal
TypedData_* macros hide assignments and are confusing and too long for users of giant fonts. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-26process.c: avoid dlclose before execk0kubun
because JIT-ed code may still be on stack at this time, unlike in ruby_cleanup(). This hopes to fix: (take 2) http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/1480207 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-26Revert "process.c: try to workaroun SEGV by r65994"k0kubun
This reverts commit 0e6aba22c6b876a36adc39cac5314ce6e626954c. because it didn't help, at all. http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/1480207 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-26process.c: try to workaroun SEGV by r65994k0kubun
http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/1480173 It tries to print C backtrace but fails. And core file on the server seems to be stopping on the irrelevant place due to its own signal handler for the dump. And I failed to reproduce this SEGV on my machine. I don't know why it's broken, so let me try this change to investigate the reason of SEGV. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-26process.c: finish MJIT prior to #execk0kubun
to prevent ruby from leaving MJIT-related files. test_jit.rb: add a test to prevent that git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-22io + socket: make pipes and sockets nonblocking by defaultnormal
All normal Ruby IO methods (IO#read, IO#gets, IO#write, ...) are all capable of appearing to be "blocking" when presented with a file description with the O_NONBLOCK flag set; so there is little risk of incompatibility within Ruby-using programs. The biggest compatibility risk is when spawning external programs. As a result, stdin, stdout, and stderr are now always made blocking before exec-family calls. This change will make an event-oriented MJIT usable if it is waiting on pipes on POSIX_like platforms. It is ALSO necessary to take advantage of (proposed lightweight concurrency (aka "auto-Fiber") or any similar proposal for network concurrency: https://bugs.ruby-lang.org/issues/13618 Named-pipe (FIFO) are NOT yet non-blocking by default since they are rarely-used and may introduce compatibility problems and extra syscall overhead for a common path. Please revert this commit if there are problems and if I am afk since I am afk a lot, lately. [ruby-core:89950] [Bug #14968] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-20process.c: do not try to pause MJITk0kubun
while child handler is disabled. trying to fix [Bug #15320] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-19revert r65807k0kubun
it didn't work. http://ci.rvm.jp/results/trunk-mjit@silicon-docker/1468677 and skips broken tests for now. But this issue should be fixed soon. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-19process.c: do not run signal handler before forkk0kubun
to prevent from proceeding one for MJIT while it's not safe yet. By that situation, MJIT worker could be waiting for compiler process forever http://ci.rvm.jp/results/trunk-mjit@silicon-docker/1468033 [Bug #15320] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-18* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-18mjit_worker.c: support MJIT in forked Ruby processk0kubun
by launching MJIT worker thread in child Ruby process. See the comment before `mjit_child_after_fork` for details. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-30support theap for T_HASH. [Feature #14989]ko1
* hash.c, internal.h: support theap for small Hash. Introduce RHASH_ARRAY (li_table) besides st_table and small Hash (<=8 entries) are managed by an array data structure. This array data can be managed by theap. If st_table is needed, then converting array data to st_table data. For st_table using code, we prepare "stlike" APIs which accepts hash value and are very similar to st_ APIs. This work is based on the GSoC achievement by tacinight <tacingiht@gmail.com> and refined by ko1. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-30process.c: implement rb_f_system without toggling ruby_nocldwaitnormal
Following how mjit_worker.c currently works, rb_f_system now ensures the VM-wide waitpid lists is locked before creating a new process via fork/vfork. This ensures other rb_waitpid callers cannot steal work and there are no possible race conditions from toggling ruby_nocldwait without the use of atomics. This sets us up for implementing MJIT process management logic using normal Ruby APIs prepares us for VM-wide asynchronous/event-base waitpid which can allow MJIT to work without worker threads. Take 2: set waitpid_state.pid on platforms w/o fork. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-30revert r65434normal
http://mswinci.japaneast.cloudapp.azure.com/vc12-x64/ruby-trunk/log/20181030T003541Z.fail.html.gz I have no chance of getting anything to work on proprietary platforms :< git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65436 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-29* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-29process.c: implement rb_f_system without toggling ruby_nocldwaitnormal
Following how mjit_worker.c currently works, rb_f_system now ensures the VM-wide waitpid lists is locked before creating a new process via fork/vfork. This ensures other rb_waitpid callers cannot steal work and there are no possible race conditions from toggling ruby_nocldwait without the use of atomics. This sets us up for implementing MJIT process management logic using normal Ruby APIs prepares us for VM-wide asynchronous/event-base waitpid which can allow MJIT to work without worker threads. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-19rb_sigwait_sleep: change internal API to use rb_hrtime_tnormal
rb_hrtime_t is a more pleasant type to use and this can make future changes around sleeping/scheduling easier. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65182 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-12process.c: [DOC] improve docs for Process.groupsstomar
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-10* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-10revisit `RARRAY_PTR()`.ko1
* process.c (check_exec_redirect): use RARRAY_AREF() instead of using RARRAY_PTR(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-19process.c (waitpid_cleanup): unconditionally remove from waitersnormal
This is the safer option, as there seems to be cases where checking waitpid_state.ret is insufficient in ensure. I'm not 100% sure why this is, but this change was required for my work-in-progress Thread::Light patch series, too... git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-27process.c: fix potential missed wakeups in r64576normal
Oddly, all existing test cases passed multiple times before this patch (even with --jit-wait), so this seems like a difficult failure to prove. Fixes: r64576 ("process.c: simplify SIGCHLD-based waitpid") git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-27process.c: simplify SIGCHLD-based waitpidnormal
Introduce a new rb_thread_sleep_interruptible that does not execute interrupts before sleeping. Skipping the interrupt check before sleep is required for out-of-GVL ruby_waitpid_all to function properly when setting waitpid_state.ret Now that ubf_select can be called by the gvl.timer thread without recursive locking gvl.lock, we can safely use rb_threadptr_interrupt to deal with waking up sleeping processes, git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e