summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-12-11 19:40:25 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-12-11 19:40:25 +0900
commit1728eba48a163c09c0e2a918c13d5c08961bf9a9 (patch)
treede334a077c3851f4e1816d4524808170085d6eca /process.c
parent885135f84cd609fb1c7be3fa0a20ae77969eae9d (diff)
[DOC] Fixed the RDoc location of Process::Status.wait [ci skip]
Diffstat (limited to 'process.c')
-rw-r--r--process.c73
1 files changed, 37 insertions, 36 deletions
diff --git a/process.c b/process.c
index 1ff203d8ee..d880ca560b 100644
--- a/process.c
+++ b/process.c
@@ -1311,6 +1311,43 @@ waitpid_no_SIGCHLD(struct waitpid_state *w)
w->errnum = errno;
}
+VALUE
+rb_process_status_wait(rb_pid_t pid, int flags)
+{
+ // We only enter the scheduler if we are "blocking":
+ if (!(flags & WNOHANG)) {
+ VALUE scheduler = rb_scheduler_current();
+ if (rb_scheduler_supports_process_wait(scheduler)) {
+ return rb_scheduler_process_wait(scheduler, pid, flags);
+ }
+ }
+
+ COROUTINE_STACK_LOCAL(struct waitpid_state, w);
+
+ waitpid_state_init(w, pid, flags);
+ w->ec = GET_EC();
+
+ if (WAITPID_USE_SIGCHLD) {
+ waitpid_wait(w);
+ }
+ else {
+ waitpid_no_SIGCHLD(w);
+ }
+
+ if (w->ret > 0) {
+ if (ruby_nocldwait) {
+ w->ret = -1;
+ w->errnum = ECHILD;
+ }
+ }
+
+ VALUE status = rb_process_status_new(w->ret, w->status, w->errnum);
+
+ COROUTINE_STACK_FREE(w);
+
+ return status;
+}
+
/*
* call-seq:
* Process::Status.wait(pid=-1, flags=0) -> Process::Status
@@ -1354,42 +1391,6 @@ waitpid_no_SIGCHLD(struct waitpid_state *w)
*
* EXPERIMENTAL FEATURE
*/
-VALUE
-rb_process_status_wait(rb_pid_t pid, int flags)
-{
- // We only enter the scheduler if we are "blocking":
- if (!(flags & WNOHANG)) {
- VALUE scheduler = rb_scheduler_current();
- if (rb_scheduler_supports_process_wait(scheduler)) {
- return rb_scheduler_process_wait(scheduler, pid, flags);
- }
- }
-
- COROUTINE_STACK_LOCAL(struct waitpid_state, w);
-
- waitpid_state_init(w, pid, flags);
- w->ec = GET_EC();
-
- if (WAITPID_USE_SIGCHLD) {
- waitpid_wait(w);
- }
- else {
- waitpid_no_SIGCHLD(w);
- }
-
- if (w->ret > 0) {
- if (ruby_nocldwait) {
- w->ret = -1;
- w->errnum = ECHILD;
- }
- }
-
- VALUE status = rb_process_status_new(w->ret, w->status, w->errnum);
-
- COROUTINE_STACK_FREE(w);
-
- return status;
-}
VALUE
rb_process_status_waitv(int argc, VALUE *argv, VALUE _)