summaryrefslogtreecommitdiff
path: root/process.c
AgeCommit message (Collapse)Author
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
2018-08-26process.c: remove worthless waitpid_sys macronormal
It is identical to do_waitpid, and the win32 version will not be needed for MJIT (since win32 does not suffer from the waitpid(-1, ...) conflict where waits can get stolen. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-21Re-Revert "Temporary revert "process.c: dead code when no SIGCHLD""naruse
This re-reverts commit r64447. The issue was machine side problem. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-18Temporary revert "process.c: dead code when no SIGCHLD"naruse
This reverts commit r64407. Maybe it breaks http://mswinci.japaneast.cloudapp.azure.com/vc12-x64/ruby-trunk/log/20180817T095734Z.fail.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-17process.c: dead code when no SIGCHLDnobu
* process.c (ruby_waitpid_all): nothing to do unless SIGCHLD is available. * signal.c (ruby_nocldwait): used only if SIGCHLD is available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-16process.c: defaults to close_others falsenormal
Arbitrarily closing file descriptors on exec breaks use cases where a Ruby process sets up a descriptor for non-Ruby children to use. For example, the "rake foo" target may spawn any number of subprocesses (Ruby or not) which depends on parsing the "FOO" environment variable for out_fd:99 and writing to foo.out FOO=out_fd:99 rake foo 99>>foo.out Unfortunately, this introduced one incompatibility in test/lib/test/unit.rb and it now requires explicitly setting IO#close_on_exec=true [ruby-core:88007] [Misc #14907] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-16thread_pthread.c: reduce ubf_timer arming for non-signal wakeupsnormal
We do not need to rely on SIGVTALRM for non-sighandler wakeups. This will reduce spurious wakeups in cases where sigwait_fd is not grabbed again, soon. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-13thread_pthread.c: eliminate timer thread by restructuring GVLnormal
This reverts commit 194a6a2c68e9c8a3536b24db18ceac87535a6051 (r64203). Race conditions which caused the original reversion will be fixed in the subsequent commit. [ruby-core:88360] [Misc #14937] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-10Fix a typo [ci skip]kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-10process.c: fix rubyspec of Process.groupsmrkn
getgroups(2) may return a GID list that includes duplicated GIDs. The behavior is totaly depends on what OS is used. This commit fixes the example of Process.groups so that the example is independent of this OS-dependent features. Additonaly, this commit adds the description of such system-dependent characteristics of Process.groups. [ruby-dev:50603] [Bug #14969] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-09process.c: don't wait JIT queue flush on rb_f_execk0kubun
This wasn't intended in r64253. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64254 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-09process.c: fix outdated mjit_pause declarationk0kubun
by sharing it with vm.c in internal.h. vm.c: ditto internal.h: ditto mjit.h: share more. mjit.c: make sure the third arguemnt is not used git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-06thread_pthread.c: restore timer-thread for now :<normal
[ruby-core:88306] Revert "process.c: ensure th->interrupt lock is held when migrating" This reverts commit 5ca416bdf6b6785cb20f139c2c514eda005fe42f (r64201) Revert "process.c (rb_waitpid): reduce sigwait_fd bouncing" This reverts commit 217bdd776fbeea3bfd0b9324eefbfcec3b1ccb3e (r64200). Revert "test/ruby/test_thread.rb (test_thread_timer_and_interrupt): add timeouts" This reverts commit 9f395f11202fc3c7edbd76f5aa6ce1f8a1e752a9 (r64199). Revert "thread_pthread.c (native_sleep): reduce ppoll sleeps" This reverts commit b3aa256c4d43d3d7e9975ec18eb127f45f623c9b (r64193). Revert "thread.c (consume_communication_pipe): do not retry after short read" This reverts commit 291a82f748de56e65fac10edefc51ec7a54a82d4 (r64185). Revert "test/ruby/test_io.rb (test_race_gets_and_close): timeout each thread" This reverts commit 3dbd8d1f66537f968f0461ed8547460b3b1241b3 (r64184). Revert "thread_pthread.c (gvl_acquire_common): persist timeout across calls" This reverts commit 8c2ae6e3ed072b06fc3cbc34fa8a14b2acbb49d5 (r64165). Revert "test/ruby/test_io.rb (test_race_gets_and_close): use SIGABRT on timeout" This reverts commit 931cda4db8afd6b544a8d85a6815765a9c417213 (r64135). Revert "thread_pthread.c (gvl_yield): do ubf wakeups when uncontended" This reverts commit 508f00314f46c08b6e9b0141c01355d24954260c (r64133). Revert "thread_pthread.h (native_thread_data): split condvars on some platforms" This reverts commit a038bf238bd9a24bf1e1622f618a27db261fc91b (r64124). Revert "process.c (waitpid_nogvl): prevent conflicting use of sleep_cond" This reverts commit 7018acc946882f21d519af7c42ccf84b22a46b27 (r64117). Revert "thread_pthread.c (rb_sigwait_sleep): th may be 0 from MJIT" This reverts commit 56491afc7916fb24f5c4dc2c632fb93fa7063992 (r64116). Revert "thread*.c: waiting on sigwait_fd performs periodic ubf wakeups" This reverts commit ab47a57a46e70634d049e4da20a5441c7a14cdec (r64115). Revert "thread_pthread.c (gvl_destroy): make no-op on GVL bits" This reverts commit 95cae748171f4754b97f4ba54da2ae62a8d484fd (r64114). Revert "thread_pthread.c (rb_sigwait_sleep): fix uninitialized poll set in UBF case" This reverts commit 4514362948fdb914c6138b12d961d92e9c0fee6c (r64113). Revert "thread_pthread.c (rb_sigwait_sleep): re-fix [Bug #5343] harder" This reverts commit 26b8a70bb309c7a367b9134045508b5b5a580a77 (r64111). Revert "thread.c: move ppoll wrapper into thread_pthread.c" This reverts commit 3dc7727d22fecbc355597edda25d2a245bf55ba1 (r64110). Revert "thread.c: move ppoll wrapper before thread_pthread.c" This reverts commit 2fa1e2e3c3c5c4b3ce84730dee4bcbe9d81b8e35 (r64109). Revert "thread_pthread.c (ubf_select): refix [Bug #5343]" This reverts commit 4c1ab82f0623eca91a95d2a44053be22bbce48ad (r64108). Revert "thread_win32.c: suppress warnings by -Wsuggest-attribute" This reverts commit 6a9b63e39075c53870933fbac5c1065f7d22047c (r64159). Revert "thread_pthread: remove timer-thread by restructuring GVL" This reverts commit 708bfd21156828526fe72de2cedecfaca6647dc1 (r64107). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e