summaryrefslogtreecommitdiff
path: root/process.c
AgeCommit message (Collapse)Author
2023-06-01Hide the usage of `rb_io_t` where possible. (#7880)Samuel Williams
This retries the compatible parts of the previously reverted PR so we can continue to update related code without breaking backwards compatibility. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-06-01Revert "Hide most of the implementation of `struct rb_io`. (#6511)"NARUSE, Yui
This reverts commit 18e55fc1e1ec20e8f3166e3059e76c885fc9f8f2. fix [Bug #19704] https://bugs.ruby-lang.org/issues/19704 This breaks compatibility for extension libraries. Such changes need a discussion.
2023-05-30Hide most of the implementation of `struct rb_io`. (#6511)Samuel Williams
* Add rb_io_path and rb_io_open_descriptor. * Use rb_io_open_descriptor to create PTY objects * Rename FMODE_PREP -> FMODE_EXTERNAL and expose it FMODE_PREP I believe refers to the concept of a "pre-prepared" file, but FMODE_EXTERNAL is clearer about what the file descriptor represents and aligns with language in the IO::Buffer module. * Ensure that rb_io_open_descriptor closes the FD if it fails If FMODE_EXTERNAL is not set, then it's guaranteed that Ruby will be responsible for closing your file, eventually, if you pass it to rb_io_open_descriptor, even if it raises an exception. * Rename IS_EXTERNAL_FD -> RUBY_IO_EXTERNAL_P * Expose `rb_io_closed_p`. * Add `rb_io_mode` to get IO mode. --------- Co-authored-by: KJ Tsanaktsidis <ktsanaktsidis@zendesk.com> Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-05-21Put `rb_fork` back into process.cNobuyoshi Nakada
Now, calling `rb_fork` directly breaks the PID cache and the timer thread, so must use `rb_fork_ruby` or similar instead. Notes: Merged: https://github.com/ruby/ruby/pull/7834
2023-04-13[Feature #19590] Show the invalid clock argumentNobuyoshi Nakada
Include the failed clock argument in the error message from `Process.clock_gettime` and `Process.clock_getres`. Notes: Merged: https://github.com/ruby/ruby/pull/7687
2023-04-05[DOC] Clarify behavior of abort() with no argumentDaniel DeLorme
Since Ruby 2.7 it prints the message and backtrace of $! Fixes [Bug #19578] Notes: Merged: https://github.com/ruby/ruby/pull/7664
2023-04-04Revert "Fix transient heap mode"Aaron Patterson
This reverts commit 87253d047ce35e7836b6f97edbb4f819879a3b25. Revert "Implement `Process.warmup`" This reverts commit ba6ccd871442f55080bffd53e33678c0726787d2.
2023-04-04Implement `Process.warmup`Jean Boussier
[Feature #18885] For now, the optimizations performed are: - Run a major GC - Compact the heap - Promote all surviving objects to oldgen Other optimizations may follow. Notes: Merged: https://github.com/ruby/ruby/pull/7346
2023-04-04PID cache is never cleared where `fork` is not usedNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/7649
2023-03-24Cache pid itself instead of converted VALUENobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/7585
2023-03-23thread_pthread.c: Use a `fork_gen` to protect against fork instead of getpid()Jean Boussier
[Feature #19443] Until recently most libc would cache `getpid()` so this was a cheap check to make. However as of glibc version 2.25 the PID cache is removed and calls to getpid() always invoke the actual system call which significantly degrades the performance of existing applications. The reason glibc removed the cache is that some libraries were bypassing fork(2) by issuing system calls themselves, causing stale cache issues. That isn't a concern for Ruby as bypassing MRI's primitive for forking would render the VM unusable, so we can safely cache the PID. Notes: Merged: https://github.com/ruby/ruby/pull/7434
2023-03-22Suppress a compiler warning on GCC in process.cPeter Zhu
rb_pid_t is 32 bits on some platforms, which will cause a warning on GCC due to POSFIXABLE always returning true. include/ruby/internal/arithmetic/fixnum.h:43:31: warning: comparison is always true due to limited range of data type [-Wtype-limits] Notes: Merged: https://github.com/ruby/ruby/pull/7580
2023-03-20Mark cached pid if necessaryNobuyoshi Nakada
2023-03-20Cache `Process.pid`Jean Boussier
[Feature #19443] It's not uncommon for database client and similar network libraries to protect themselves from Process.fork by regularly checking Process.pid Until recently most libc would cache `getpid()` so this was a cheap check to make. However as of glibc version 2.25 the PID cache is removed and calls to `getpid()` always invoke the actual system call which significantly degrades the performance of existing applications. The reason glibc removed the cache is that some libraries were bypassing `fork(2)` by issuing system calls themselves, causing stale cache issues. That isn't a concern for Ruby as bypassing MRI's primitive for forking would render the VM unusable, so we can safely cache the PID. Notes: Merged: https://github.com/ruby/ruby/pull/7326
2023-03-15Remove SIGCHLD `waidpid`. (#7527)Samuel Williams
* Remove `waitpid_lock` and related code. * Remove un-necessary test. * Remove `rb_thread_sleep_interruptible` dead code. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-03-14Revert SIGCHLD changes to diagnose CI failures. (#7517)Samuel Williams
* Revert "Remove special handling of `SIGCHLD`. (#7482)" This reverts commit 44a0711eab7fbc71ac2c8ff489d8c53e97a8fe75. * Revert "Remove prototypes for functions that are no longer used. (#7497)" This reverts commit 4dce12bead3bfd91fd80b5e7195f7f540ffffacb. * Revert "Remove SIGCHLD `waidpid`. (#7476)" This reverts commit 1658e7d96696a656d9bd0a0c84c82cde86914ba2. * Fix change to rjit variable name. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-03-10Remove prototypes for functions that are no longer used. (#7497)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-03-10Accept `sleep(nil)` as sleep forever. (#7484)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-03-09Remove SIGCHLD `waidpid`. (#7476)Samuel Williams
* Remove `waitpid_lock` and related code. * Remove un-necessary test. * Remove `rb_thread_sleep_interruptible` dead code. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-03-07Remove obsoleted functions in rjit.cTakashi Kokubun
2023-03-07Get rid of MJIT's special forkTakashi Kokubun
2023-03-06s/mjit/rjit/Takashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/7462
2023-03-06s/MJIT/RJIT/Takashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/7462
2023-02-19[DOC] Restore Process module doc lost due to RDoc updatezverok
Notes: Merged: https://github.com/ruby/ruby/pull/7316
2022-11-19[DOC] Change formatting in the exec docsMaciek Rząsa
The last part of the sentence was accidentally put in enumeration, It made an impression that it's one of the rules, not the result of applying the rules. Notes: Merged: https://github.com/ruby/ruby/pull/6762 Merged-By: nobu <nobu@ruby-lang.org>
2022-11-16Using UNDEF_P macroS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/6721
2022-09-22Followed up 796069b2882d8a67ecc36bda7c72affcbad09daeHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/6415
2022-09-21getrlimit adding RLIMIT_NPTS constant.David Carlier
Notes: Merged: https://github.com/ruby/ruby/pull/4377
2022-09-21[DOC] Tweak the doc for `Process.kill` signatureKoichi ITO
Replacing `...` with `*pids` seems to clarify the expected variadic arguments. Note that the expected arguments are two or more with a signal and pids. That is, the method must have at least one pid, which cannot be omitted: ```console % ruby -e 'Process.kill(0)' -e:1:in `kill': wrong number of arguments (given 1, expected 2+) (ArgumentError) from -e:1:in `<main>' ``` Notes: Merged: https://github.com/ruby/ruby/pull/5928
2022-09-20Ignore EPERM which means already being process-leaderNobuyoshi Nakada
2022-09-19Reduce fork calls in daemonNobuyoshi Nakada
The forked child process is a grandchild process from the viewpoint of the process which invoked the caller process. That means the child is detached at that point, and it does not need to fork twice. Notes: Merged: https://github.com/ruby/ruby/pull/6402
2022-09-11MJIT: Do not hang after forking with threadsTakashi Kokubun
First, rb_mjit_fork should call rb_thread_atfork to stop threads after fork in the child process. Unfortunately, we cannot use rb_fork_ruby to prevent this kind of mistakes because MJIT needs special handling of waiting_pid and mjit_pause/resume. Second, mjit_waitpid_finished should be checked regardless of trap_interrupt. It doesn't seem like the flag is not set when SIGCHLD is handled for an MJIT child process.
2022-09-04Call appropriate hooks on MJIT's forkTakashi Kokubun
This takes care of signal_self_pipe and other things.
2022-08-12Short-circuit `Process._fork`Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6139
2022-08-07Stop using casted `rb_syswait` as `proc_syswait`Nobuyoshi Nakada
The argument of `rb_syswait` is now `rb_pid_t` which may differ from `int`. Also it is an undefined behavior to take the result of casted void function (in `rb_protect`).
2022-08-06Fix the sizes comparisonNobuyoshi Nakada
`proc_syswait` will be called with a `VALUE` argument.
2022-08-05[DOC] Process._fork does not get called by Process.daemonIvo Anjo
As discussed in [Bug #18911], I'm adding some documentation to `Process._fork` to clarify that it is not expected to cover calls to `Process.daemon`. [Bug #18911]: https://bugs.ruby-lang.org/issues/18911 Co-authored-by: Yusuke Endoh <mame@ruby-lang.org> Notes: Merged: https://github.com/ruby/ruby/pull/6170 Merged-By: nobu <nobu@ruby-lang.org>
2022-07-21Expand tabs [ci skip]Takashi Kokubun
[Misc #18891] Notes: Merged: https://github.com/ruby/ruby/pull/6094
2022-06-28[DOC] Document `Process::Tms`Nobuyoshi Nakada
2022-06-20Allow to just warn as bool expected, without an exceptionNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6039
2022-06-15Remove MJIT worker thread (#6006)Takashi Kokubun
[Misc #18830] Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2022-04-13[ci skip] Fix docsPeter Zhu
2022-04-08Fix some RDoc links (#5778)Burdette Lamar
Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
2022-03-30Prefix ccan headers (#4568)Nobuyoshi Nakada
* Prefixed ccan headers * Remove unprefixed names in ccan/build_assert * Remove unprefixed names in ccan/check_type * Remove unprefixed names in ccan/container_of * Remove unprefixed names in ccan/list Co-authored-by: Samuel Williams <samuel.williams@oriontransfer.co.nz> Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-03-07[DOC] Fix documentation typo for Process#clock_gettimeThierry Joyal
Fixes [Misc #18610] Notes: Merged: https://github.com/ruby/ruby/pull/5625
2022-02-19Use symbols for clock IDs if `clockid_t` is not numericNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5574
2022-02-19Set static IDs to same name variablesNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5574
2022-02-18Enhanced RDoc concerning command injection (#5537)Burdette Lamar
Clarifies security vulnerabilities for commands. Treats: Kernel.system Kernel.` (backtick) IO.popen IO.read IO.write IO.binread IO.binwrite IO.readlines IO.foreach Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
2022-01-21Accurately report VM memsizeKevin Newton
Currently the calculation only counts the size of the struct. This commit adds the size of the associated st tables, id tables, and linked lists. Still missing is the size of the ractors and (potentially) the size of the object space. Notes: Merged: https://github.com/ruby/ruby/pull/5428
2022-01-19[DOC] Enhanced Process.groups relatedNobuyoshi Nakada
* On some platforms (e.g., macOS), the user's default group access list may exceed `NGROUPS_MAX`. * Use upcase "GID" instead of "gid" for other than variable names.