summaryrefslogtreecommitdiff
path: root/process.c
Commit message (Collapse)AuthorAgeFilesLines
...
* process.c: Add Process._fork (#5017)Yusuke Endoh2021-10-251-9/+39
| | | | | | | | | | * process.c: Add Process._fork This API is supposed for application monitoring libraries to hook fork event. [Feature #17795] Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
* Fill pid and error in the statusNobuyoshi Nakada2021-10-191-2/+7
|
* Rework order of operations to better handle last_status.Samuel Williams2021-09-221-9/+6
|
* Add support for non-blocking `Kernel.system`.Samuel Williams2021-09-221-64/+109
|
* Handle overwriting Object::ENV in spawnJeremy Evans2021-09-141-5/+6
| | | | | | | | | Instead of looking for Object::ENV (which can be overwritten), directly look for the envtbl variable. As that is static in hash.c, and the lookup code is in process.c, add a couple non-static functions that will return envtbl (or envtbl#to_hash). Fixes [Bug #18164]
* Replace RBOOL macroS-H-GAMELINKS2021-09-051-1/+1
|
* Add Windows as a supported OS for Process.clock_gettime [ci skip]Lars Kanis2021-08-281-2/+2
|
* `popen()` is not available on emscriptenNobuyoshi Nakada2021-08-161-1/+1
|
* Suppress unused-variable warningsNobuyoshi Nakada2021-08-161-2/+2
|
* [DOC] mention how the command is passed to the shell [ci skip]Nobuyoshi Nakada2021-08-031-1/+2
|
* [DOC] Fix Process::exec documentation [ci skip]Nobuyoshi Nakada2021-07-311-1/+1
| | | | | | Shell reserved words and special built-in commands can be placed at only the beginning of the command (except for leading white spaces).
* [DOC] Fix Process::exec documentation [ci skip]Nobuyoshi Nakada2021-07-301-2/+2
| | | | | The environment variable `RUBYSHELL` is used only on Windows, as well as `COMSPEC`.
* Remove unneeded function declarationsS.H2021-07-221-4/+0
|
* process.c: Call rb_thread_atfork in rb_fork_rubyYusuke Endoh2021-07-151-3/+4
| | | | | | | | All occurrences of rb_fork_ruby are followed by a call rb_thread_fork in the created child process. This is refactoring and a potential preparation for [Feature #17795]. (rb_fork_ruby may be wrapped by Process._fork_.)
* Replace copy coroutine with pthread implementation.Samuel Williams2021-07-011-14/+10
|
* Expose scheduler as public interface & bug fixes. (#3945)Samuel Williams2021-02-091-7/+6
| | | | | | | | | * Rename `rb_scheduler` to `rb_fiber_scheduler`. * Use public interface if available. * Use `rb_check_funcall` where possible. * Don't use `unblock` unless the fiber was non-blocking.
* Updated access to Process::Status attributesNobuyoshi Nakada2020-12-241-14/+25
| | | | | pst_pid() no longer returns Qnil even if the receiver is not initialized.
* Store errno in struct rb_process_statusNobuyoshi Nakada2020-12-241-16/+21
| | | | | To propagate errno in the fiber thread scheduler hook. Returns nil when no terminated process.
* Struct::Tms: delete卜部昌平2020-12-221-3/+0
| | | | Has been deprecated since 44c53ee473d3b3973cb5c3ce03fbf4f280fd75ff.
* Fixed indefinite articles before "Integer" [ci skip]Nobuyoshi Nakada2020-12-211-1/+1
|
* Remove unused variableRadosław Bułat2020-12-191-2/+1
|
* Revert "Better cooperation between public/protected/private with attr* and ↵Yusuke Endoh2020-12-181-1/+2
| | | | | | alias_method" This reverts commit 81739ad4fdfcc86a769056fec352f27c686fba1b.
* Better cooperation between public/protected/private with attr* and alias_methodRadosław Bułat2020-12-171-2/+1
|
* Fixed marshal compatibility of Process::StatusNobuyoshi Nakada2020-12-161-0/+25
|
* [DOC] Process::Status.wait return nil if no child processes [ci skip]Nobuyoshi Nakada2020-12-121-3/+3
|
* RDoc states that Process::Status.wait returns nil if cannot waitNobuyoshi Nakada2020-12-111-25/+16
|
* [DOC] Fixed the RDoc location of Process::Status.wait [ci skip]Nobuyoshi Nakada2020-12-111-36/+37
|
* [DOC] Moved RDoc of abort [ci skip]Nobuyoshi Nakada2020-12-111-11/+12
|
* Tweaked `Process::Status.wait`Nobuyoshi Nakada2020-12-091-17/+25
| | | | | | | | * revert `rb_last_status_set` * renamed the new function as `rb_process_status_new` * `rb_process_status_new` always freezes the return value * marked `Process::Status.wait` as EXPERIMENTAL, as it has not been discussed totally yet.
* Add support for non-blocking `Process.wait`.Samuel Williams2020-12-091-38/+174
|
* Revert getaddrinfo_a()Masaki Matsushita2020-12-071-10/+0
| | | | | | | | getaddrinfo_a() gets stuck after fork(). To avoid this, we need 1 second sleep to wait for internal worker threads of getaddrinfo_a() to be finished, but that is unacceptable. [Bug #17220] [Feature #17134] [Feature #17187]
* Call cleanup function for getaddrinfo_a(3) only before fork()Masaki Matsushita2020-12-061-9/+14
| | | | | | Previously, rb_getaddrinfo_a_before_exec() is called from before_exec(). However, the function needs to be called only before fork(). The change moves it to before_fork().
* Add a hook before fork() for getaddrinfo_a()Masaki Matsushita2020-12-041-0/+10
| | | | | | | | | We need stop worker threads in getaddrinfo_a() before fork(). This change adds a hook before fork() that cancel all outstanding requests and wait for all ongoing requests. Then, it waits for all worker threads to be finished. Fixes [Bug #17220]
* Remove obsoleted internal/mjit.h inclusionTakashi Kokubun2020-11-221-1/+1
| | | | :bow:
* fix public interfaceKoichi Sasada2020-11-181-1/+1
| | | | | | | | | | | | | | | | | | To make some kind of Ractor related extensions, some functions should be exposed. * include/ruby/thread_native.h * rb_native_mutex_* * rb_native_cond_* * include/ruby/ractor.h * RB_OBJ_SHAREABLE_P(obj) * rb_ractor_shareable_p(obj) * rb_ractor_std*() * rb_cRactor and rm ractor_pub.h and rename srcdir/ractor.h to srcdir/ractor_core.h (to avoid conflict with include/ruby/ractor.h)
* Rename to `Fiber#set_scheduler`.Samuel Williams2020-11-071-1/+1
|
* freeze Process::StatusKoichi Sasada2020-10-271-0/+1
| | | | It seems immutable information.
* Don't redefine #rb_intern over and over againStefan Stüben2020-10-211-33/+31
|
* Some global variables can be accessed from ractorsKoichi Sasada2020-10-201-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some global variables should be used from non-main Ractors. [Bug #17268] ```ruby # ractor-local (derived from created ractor): debug '$DEBUG' => $DEBUG, '$-d' => $-d, # ractor-local (derived from created ractor): verbose '$VERBOSE' => $VERBOSE, '$-w' => $-w, '$-W' => $-W, '$-v' => $-v, # process-local (readonly): other commandline parameters '$-p' => $-p, '$-l' => $-l, '$-a' => $-a, # process-local (readonly): getpid '$$' => $$, # thread local: process result '$?' => $?, # scope local: match '$~' => $~.inspect, '$&' => $&, '$`' => $`, '$\'' => $', '$+' => $+, '$1' => $1, # scope local: last line '$_' => $_, # scope local: last backtrace '$@' => $@, '$!' => $!, # ractor local: stdin, out, err '$stdin' => $stdin.inspect, '$stdout' => $stdout.inspect, '$stderr' => $stderr.inspect, ```
* Prefer `rb_thread_current_scheduler`.Samuel Williams2020-09-141-1/+1
|
* Standardised scheduler interface.Samuel Williams2020-09-141-1/+3
|
* Introduce Ractor mechanism for parallel executionKoichi Sasada2020-09-031-1/+2
| | | | | | | | | | | | | | | | This commit introduces Ractor mechanism to run Ruby program in parallel. See doc/ractor.md for more details about Ractor. See ticket [Feature #17100] to see the implementation details and discussions. [Feature #17100] This commit does not complete the implementation. You can find many bugs on using Ractor. Also the specification will be changed so that this feature is experimental. You will see a warning when you make the first Ractor with `Ractor.new`. I hope this feature can help programmers from thread-safety issues.
* Fix type of getlogin_r's 2nd argumentKazuhiro NISHIYAMA2020-08-221-1/+7
| | | | | | | | | | | | | | | | https://rubyci.org/logs/rubyci.s3.amazonaws.com/freebsd12/ruby-master/log/20200821T223002Z.fail.html.gz ``` process.c:5593:37: error: implicit conversion loses integer precision: 'long' to 'int' [-Werror,-Wshorten-64-to-32] while ((gle = getlogin_r(login, loginsize)) != 0) { ~~~~~~~~~~ ^~~~~~~~~ ``` type of getlogin_r's 2nd argument is - int on FreeBSD - https://www.freebsd.org/cgi/man.cgi?query=getlogin_r&apropos=0&sektion=0&manpath=FreeBSD+12.1-RELEASE+and+Ports&arch=default&format=html - size_t on Linux, NetBSD - https://man7.org/linux/man-pages/man3/getlogin_r.3.html - https://www.freebsd.org/cgi/man.cgi?query=getlogin_r&apropos=0&sektion=0&manpath=NetBSD+9.0&arch=default&format=html
* Rename `rb_current_thread_scheduler` to `rb_thread_scheduler_if_nonblocking`.Samuel Williams2020-07-201-1/+1
| | | | | Correctly capture thread before releasing GVL and pass as argument to `rb_thread_scheduler_if_nonblocking`.
* add UNREACHABLE_RETURN卜部昌平2020-06-291-0/+1
| | | | | | Not every compilers understand that rb_raise does not return. When a function does not end with a return statement, such compilers can issue warnings. We would better tell them about reachabilities.
* check_exec_redirect: do not goto into a branch卜部昌平2020-06-291-2/+1
| | | | | I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
* check_exec_redirect_fd: do not goto into a branch卜部昌平2020-06-291-2/+4
| | | | | I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
* Use the dedicated conversion macroNobuyoshi Nakada2020-06-091-1/+1
|
* Return seconds slept after Thread.scheduler wait_sleepnicholas a. evans2020-06-091-9/+9
| | | | | | Kernel#sleep should still return seconds slept, even when using a Thread.scheduler. The return value of Scheduler#wait_sleep can be ignored.
* Allow Dir.home to work for non-login procs when $HOME not setAlan D. Salewski2020-05-231-2/+264
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow the 'Dir.home' method to reliably locate the user's home directory when all three of the following are true at the same time: 1. Ruby is running on a Unix-like OS 2. The $HOME environment variable is not set 3. The process is not a descendant of login(1) (or a work-alike) The prior behavior was that the lookup could only work for login-descended processes. This is accomplished by looking up the user's record in the password database by uid (getpwuid_r(3)) as a fallback to the lookup by name (getpwname_r(3)) which is still attempted first (based on the name, if any, returned by getlogin_r(3)). If getlogin_r(3), getpwnam_r(3), and/or getpwuid_r(3) is not available at compile time, will fallback on using their respective non-*_r() variants: getlogin(3), getpwnam(3), and/or getpwuid(3). The rationale for attempting to do the lookup by name prior to doing it by uid is to accommodate the possibility of multiple login names (each with its own record in the password database, so each with a potentially different home directory) being mapped to the same uid (as is explicitly allowed for by POSIX; see getlogin(3posix)). Preserves the existing behavior for login-descended processes, and adds the new capability of having Dir.home being able to find the user's home directory for non-login-descended processes. Fixes [Bug #16787] Related discussion: https://bugs.ruby-lang.org/issues/16787 https://github.com/ruby/ruby/pull/3034