Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions include/ruby/internal/intern/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ RBIMPL_SYMBOL_EXPORT_BEGIN()

/* process.c */

/**
* Returns the Ruby value representing a waitpid(2) outcome.
*
* This is intended for Fiber Scheduler implementations of process_wait. The
* returned value should be returned from the scheduler hook.
*
* @param[in] pid The process ID returned by waitpid(2), or -1 on error.
* @param[in] status The "waitpid status", as returned by waitpid(2). This is NOT the exit status/exit code, see waitpid(2).
* @param[in] error Error code when pid is -1.
* @return The Ruby value representing this process wait result.
*/
VALUE rb_process_status_for(rb_pid_t pid, int status, int error);

/**
* Wait for the specified process to terminate, reap it, and return its status.
*
Expand Down
6 changes: 3 additions & 3 deletions process.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ proc_s_last_status(VALUE mod)
}

VALUE
rb_process_status_new(rb_pid_t pid, int status, int error)
rb_process_status_for(rb_pid_t pid, int status, int error)
{
VALUE last_status = rb_process_status_allocate(rb_cProcessStatus);
struct rb_process_status *data = RTYPEDDATA_GET_DATA(last_status);
Expand Down Expand Up @@ -681,7 +681,7 @@ process_status_load(VALUE real_obj, VALUE load_obj)
void
rb_last_status_set(int status, rb_pid_t pid)
{
GET_THREAD()->last_status = rb_process_status_new(pid, status, 0);
GET_THREAD()->last_status = rb_process_status_for(pid, status, 0);
}

static void
Expand Down Expand Up @@ -1112,7 +1112,7 @@ rb_process_status_wait(rb_pid_t pid, int flags)

if (waitpid_state.ret == 0) return Qnil;

return rb_process_status_new(waitpid_state.ret, waitpid_state.status, waitpid_state.errnum);
return rb_process_status_for(waitpid_state.ret, waitpid_state.status, waitpid_state.errnum);
}

/*
Expand Down