Ruby: process.c File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Data Structures | Macros | Typedefs | Functions | Variables
process.c File Reference
`#include "ruby/internal/config.h"`
`#include "internal/scheduler.h"`
`#include "coroutine/Stack.h"`
`#include <ctype.h>`
`#include <errno.h>`
`#include <signal.h>`
`#include <stdarg.h>`
`#include <stdio.h>`
`#include <time.h>`
`#include <sys/stat.h>`
`#include "dln.h"`
`#include "hrtime.h"`
`#include "internal.h"`
`#include "internal/bits.h"`
`#include "internal/dir.h"`
`#include "internal/error.h"`
`#include "internal/eval.h"`
`#include "internal/hash.h"`
`#include "internal/object.h"`
`#include "internal/process.h"`
`#include "internal/thread.h"`
`#include "internal/variable.h"`
`#include "internal/warnings.h"`
`#include "mjit.h"`
`#include "ruby/io.h"`
`#include "ruby/st.h"`
`#include "ruby/thread.h"`
`#include "ruby/util.h"`
`#include "vm_core.h"`
`#include "ruby/ractor.h"`

Go to the source code of this file.

## Data Structures
struct | rb_process_status
struct | waitpid_state
struct | string_part
struct | open_struct
struct | run_exec_dup2_fd_pair
struct | spawn_args
struct | timetick

## Macros
#define | EXIT_SUCCESS 0
#define | EXIT_FAILURE 1
#define | MAXPATHLEN 1024
#define | WIFEXITED(w) (((w) & 0xff) == 0)
#define | WIFSIGNALED(w) (((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f))
#define | WEXITSTATUS(w) (((w) >> 8) & 0xff)
#define | WTERMSIG(w) ((w) & 0x7f)
#define | WSTOPSIG WEXITSTATUS
#define | p_uid_from_name p_uid_from_name
#define | p_gid_from_name p_gid_from_name
#define | PREPARE_GETPWNAM /* do nothing */
#define | FINISH_GETPWNAM /* do nothing */
#define | OBJ2UID1(id) NUM2UIDT(id)
#define | OBJ2UID(id) NUM2UIDT(id)
#define | p_uid_from_name rb_f_notimplement
#define | PREPARE_GETGRNAM /* do nothing */
#define | FINISH_GETGRNAM /* do nothing */
#define | OBJ2GID1(id) NUM2GIDT(id)
#define | OBJ2GID(id) NUM2GIDT(id)
#define | p_gid_from_name rb_f_notimplement
#define | id_exception idException
#define | ALWAYS_NEED_ENVP 0
#define | redirect_dup(oldfd) dup(oldfd)
#define | redirect_dup2(oldfd, newfd) dup2((oldfd), (newfd))
#define | redirect_cloexec_dup(oldfd) rb_cloexec_dup(oldfd)
#define | redirect_cloexec_dup2(oldfd, newfd) rb_cloexec_dup2((oldfd), (newfd))
#define | redirect_close(fd) close_unless_reserved(fd)
#define | parent_redirect_open(pathname, flags, perm) rb_cloexec_open((pathname), (flags), (perm))
#define | parent_redirect_close(fd) close_unless_reserved(fd)
#define | PST2INT(st) pst_status(st)
#define | WAITPID_LOCK_ONLY ((struct waitpid_state *)-1)
#define | ruby_nocldwait 0
#define | WRITE_CONST(fd, str) (void)(write((fd),(str),sizeof(str)-1)<0)
#define | try_with_sh(err, prog, argv, envp) (void)0
#define | EXPORT_STR(str) (str)
#define | EXPORT_DUP(str) rb_str_dup(str)
#define | USE_SPAWNV 0
#define | P_NOWAIT _P_NOWAIT
#define | TO_BOOL(val, name) NIL_P(val) ? 0 : rb_bool_expected((val), name)
#define | ENVMATCH(n1, n2) (strcmp((n1), (n2)) == 0)
#define | CHILD_ERRMSG_BUFLEN 80
#define | ERRMSG(str) do { if (errmsg && 0 < errmsg_buflen) strlcpy(errmsg, (str), errmsg_buflen); } while (0)
#define | ERRMSG1(str, a) do { if (errmsg && 0 < errmsg_buflen) snprintf(errmsg, errmsg_buflen, (str), (a)); } while (0)
#define | ERRMSG2(str, a, b) do { if (errmsg && 0 < errmsg_buflen) snprintf(errmsg, errmsg_buflen, (str), (a), (b)); } while (0)
#define | rb_f_fork rb_f_notimplement
#define | proc_getpgrp rb_f_notimplement
#define | proc_setpgrp rb_f_notimplement
#define | proc_getpgid rb_f_notimplement
#define | proc_setpgid rb_f_notimplement
#define | proc_getsid rb_f_notimplement
#define | proc_setsid rb_f_notimplement
#define | proc_getpriority rb_f_notimplement
#define | proc_setpriority rb_f_notimplement
#define | proc_getrlimit rb_f_notimplement
#define | proc_setrlimit rb_f_notimplement
#define | p_sys_setuid rb_f_notimplement
#define | p_sys_setruid rb_f_notimplement
#define | p_sys_seteuid rb_f_notimplement
#define | p_sys_setreuid rb_f_notimplement
#define | p_sys_setresuid rb_f_notimplement
#define | proc_setuid rb_f_notimplement
#define | p_sys_setgid rb_f_notimplement
#define | p_sys_setrgid rb_f_notimplement
#define | p_sys_setegid rb_f_notimplement
#define | p_sys_setregid rb_f_notimplement
#define | p_sys_setresgid rb_f_notimplement
#define | p_sys_issetugid rb_f_notimplement
#define | proc_setgid rb_f_notimplement
#define | proc_getgroups rb_f_notimplement
#define | proc_setgroups rb_f_notimplement
#define | proc_initgroups rb_f_notimplement
#define | proc_getmaxgroups rb_f_notimplement
#define | proc_setmaxgroups rb_f_notimplement
#define | proc_daemon rb_f_notimplement
#define | proc_seteuid_m rb_f_notimplement
#define | proc_setegid_m rb_f_notimplement
#define | rb_proc_times rb_f_notimplement
#define | TIMETICK_INT_MIN LONG_MIN
#define | TIMETICK_INT_MAX LONG_MAX
#define | TIMETICK_INT2NUM(v) LONG2NUM(v)
#define | MUL_OVERFLOW_TIMETICK_P(a, b) MUL_OVERFLOW_LONG_P(a, b)
#define | NDIV(x, y) (-(-((x)+1)/(y))-1)
#define | DIV(n, d) ((n)<0 ? NDIV((n),(d)) : (n)/(d))
#define | RUBY_TIME_BASED_CLOCK_REALTIME ID2SYM(id_TIME_BASED_CLOCK_REALTIME)
#define | RUBY_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID ID2SYM(id_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID)

## Typedefs
typedef unsigned int | unsigned_clock_t
typedef void(* | sig_t) (int)
typedef long | timetick_int_t

## Functions
VALUE | rb_last_status_get (void)
VALUE | rb_process_status_new (rb_pid_t pid, int status, int error)
void | rb_last_status_set (int status, rb_pid_t pid)
void | rb_last_status_clear (void)
void | rb_native_mutex_lock (rb_nativethread_lock_t *)
void | rb_native_mutex_unlock (rb_nativethread_lock_t *)
void | rb_native_cond_signal (rb_nativethread_cond_t *)
void | rb_native_cond_wait (rb_nativethread_cond_t *, rb_nativethread_lock_t *)
int | rb_sigwait_fd_get (const rb_thread_t *)
void | rb_sigwait_sleep (const rb_thread_t *, int fd, const rb_hrtime_t *)
void | rb_sigwait_fd_put (const rb_thread_t *, int fd)
void | rb_thread_sleep_interruptible (void)
void | rb_sigwait_fd_migrate (rb_vm_t *vm)
void | ruby_waitpid_all (rb_vm_t *vm)
rb_pid_t | ruby_waitpid_locked (rb_vm_t *vm, rb_pid_t pid, int *status, int options, rb_nativethread_cond_t *cond)
VALUE | rb_process_status_wait (rb_pid_t pid, int flags)
VALUE | rb_process_status_waitv (int argc, VALUE *argv, VALUE _)
rb_pid_t | rb_waitpid (rb_pid_t pid, int *st, int flags)
VALUE | rb_detach_process (rb_pid_t pid)
int | rb_proc_exec (const char *str)
int | rb_execarg_addopt (VALUE execarg_obj, VALUE key, VALUE val)
VALUE | rb_execarg_extract_options (VALUE execarg_obj, VALUE opthash)
struct rb_execarg * | rb_execarg_get (VALUE execarg_obj)
VALUE | rb_execarg_new (int argc, const VALUE *argv, int accept_shell, int allow_exc_opt)
void | rb_execarg_setenv (VALUE execarg_obj, VALUE env)
void | rb_execarg_parent_start (VALUE execarg_obj)
void | rb_execarg_parent_end (VALUE execarg_obj)
VALUE | rb_f_exec (int argc, const VALUE *argv)
int | rb_execarg_run_options (const struct rb_execarg *eargp, struct rb_execarg *sargp, char *errmsg, size_t errmsg_buflen)
int | rb_exec_async_signal_safe (const struct rb_execarg *eargp, char *errmsg, size_t errmsg_buflen)
void | rb_exit (int status)
VALUE | rb_f_exit (int argc, const VALUE *argv)
VALUE | rb_f_abort (int argc, const VALUE *argv)
void | rb_syswait (rb_pid_t pid)
char * | rb_execarg_commandline (const struct rb_execarg *eargp, VALUE *prog)
rb_pid_t | rb_spawn_err (int argc, const VALUE *argv, char *errmsg, size_t errmsg_buflen)
rb_pid_t | rb_spawn (int argc, const VALUE *argv)
void | InitVM_process (void)
void | Init_process (void)

## Variables
VALUE | rb_mProcess

## Macro Definition Documentation

## ◆ ALWAYS_NEED_ENVP

#define ALWAYS_NEED_ENVP 0

Definition at line 342 of file process.c.

## ◆ CHILD_ERRMSG_BUFLEN

#define CHILD_ERRMSG_BUFLEN 80

## ◆ DIV

#define DIV | ( |  | n,
|  |  | d
| ) |  | ((n)<0 ? NDIV((n),(d)) : (n)/(d))

Definition at line 8020 of file process.c.

## ◆ ENVMATCH

#define ENVMATCH | ( |  | n1,
|  |  | n2
| ) |  | (strcmp((n1), (n2)) == 0)

Definition at line 2520 of file process.c.

## ◆ ERRMSG

#define ERRMSG | ( |  | str | ) | do { if (errmsg && 0 < errmsg_buflen) strlcpy(errmsg, (str), errmsg_buflen); } while (0)

Definition at line 3222 of file process.c.

## ◆ ERRMSG1

#define ERRMSG1 | ( |  | str,
|  |  | a
| ) |  | do { if (errmsg && 0 < errmsg_buflen) snprintf(errmsg, errmsg_buflen, (str), (a)); } while (0)

Definition at line 3223 of file process.c.

## ◆ ERRMSG2

#define ERRMSG2 | ( |  | str,
|  |  | a,
|  |  | b
| ) |  | do { if (errmsg && 0 < errmsg_buflen) snprintf(errmsg, errmsg_buflen, (str), (a), (b)); } while (0)

Definition at line 3224 of file process.c.

## ◆ EXIT_FAILURE

#define EXIT_FAILURE 1

Definition at line 47 of file process.c.

## ◆ EXIT_SUCCESS

#define EXIT_SUCCESS 0

Definition at line 43 of file process.c.

## ◆ EXPORT_DUP

#define EXPORT_DUP | ( |  | str | ) | rb_str_dup(str)

Definition at line 1954 of file process.c.

## ◆ EXPORT_STR

#define EXPORT_STR | ( |  | str | ) | (str)

Definition at line 1953 of file process.c.

## ◆ FINISH_GETGRNAM

#define FINISH_GETGRNAM /* do nothing */

Definition at line 290 of file process.c.

## ◆ FINISH_GETPWNAM

#define FINISH_GETPWNAM /* do nothing */

Definition at line 247 of file process.c.

## ◆ id_exception

#define id_exception idException

Definition at line 310 of file process.c.

## ◆ MAXPATHLEN

#define MAXPATHLEN 1024

Definition at line 67 of file process.c.

## ◆ MUL_OVERFLOW_TIMETICK_P

#define MUL_OVERFLOW_TIMETICK_P | ( |  | a,
|  |  | b
| ) |  | MUL_OVERFLOW_LONG_P(a, b)

Definition at line 7922 of file process.c.

## ◆ NDIV

#define NDIV | ( |  | x,
|  |  | y
| ) |  | (-(-((x)+1)/(y))-1)

Definition at line 8019 of file process.c.

## ◆ OBJ2GID

#define OBJ2GID | ( |  | id | ) | NUM2GIDT(id)

Definition at line 292 of file process.c.

## ◆ OBJ2GID1

#define OBJ2GID1 | ( |  | id | ) | NUM2GIDT(id)

Definition at line 291 of file process.c.

## ◆ OBJ2UID

#define OBJ2UID | ( |  | id | ) | NUM2UIDT(id)

Definition at line 249 of file process.c.

## ◆ OBJ2UID1

#define OBJ2UID1 | ( |  | id | ) | NUM2UIDT(id)

Definition at line 248 of file process.c.

## ◆ p_gid_from_name [1/2]

#define p_gid_from_name p_gid_from_name

Definition at line 295 of file process.c.

## ◆ p_gid_from_name [2/2]

#define p_gid_from_name rb_f_notimplement

Definition at line 295 of file process.c.

## ◆ P_NOWAIT

#define P_NOWAIT _P_NOWAIT

Definition at line 1963 of file process.c.

## ◆ p_sys_issetugid

#define p_sys_issetugid rb_f_notimplement

Definition at line 6675 of file process.c.

## ◆ p_sys_setegid

#define p_sys_setegid rb_f_notimplement

Definition at line 6593 of file process.c.

## ◆ p_sys_seteuid

#define p_sys_seteuid rb_f_notimplement

Definition at line 6213 of file process.c.

## ◆ p_sys_setgid

#define p_sys_setgid rb_f_notimplement

Definition at line 6549 of file process.c.

## ◆ p_sys_setregid

#define p_sys_setregid rb_f_notimplement

Definition at line 6620 of file process.c.

## ◆ p_sys_setresgid

#define p_sys_setresgid rb_f_notimplement

Definition at line 6647 of file process.c.

## ◆ p_sys_setresuid

#define p_sys_setresuid rb_f_notimplement

Definition at line 6272 of file process.c.

## ◆ p_sys_setreuid

#define p_sys_setreuid rb_f_notimplement

Definition at line 6242 of file process.c.

## ◆ p_sys_setrgid

#define p_sys_setrgid rb_f_notimplement

Definition at line 6571 of file process.c.

## ◆ p_sys_setruid

#define p_sys_setruid rb_f_notimplement

Definition at line 6191 of file process.c.

## ◆ p_sys_setuid

#define p_sys_setuid rb_f_notimplement

Definition at line 6169 of file process.c.

## ◆ p_uid_from_name [1/2]

#define p_uid_from_name p_uid_from_name

Definition at line 252 of file process.c.

## ◆ p_uid_from_name [2/2]

#define p_uid_from_name rb_f_notimplement

Definition at line 252 of file process.c.

## ◆ parent_redirect_close

#define parent_redirect_close | ( |  | fd | ) | close_unless_reserved(fd)

Definition at line 468 of file process.c.

## ◆ parent_redirect_open

#define parent_redirect_open | ( |  | pathname,
|  |  | flags,
|  |  | perm
| ) |  | rb_cloexec_open((pathname), (flags), (perm))

Definition at line 467 of file process.c.

## ◆ PREPARE_GETGRNAM

#define PREPARE_GETGRNAM /* do nothing */

Definition at line 289 of file process.c.

## ◆ PREPARE_GETPWNAM

#define PREPARE_GETPWNAM /* do nothing */

Definition at line 246 of file process.c.

## ◆ proc_daemon

#define proc_daemon rb_f_notimplement

Definition at line 7046 of file process.c.

## ◆ proc_getgroups

#define proc_getgroups rb_f_notimplement

Definition at line 6836 of file process.c.

## ◆ proc_getmaxgroups

#define proc_getmaxgroups rb_f_notimplement

Definition at line 6936 of file process.c.

## ◆ proc_getpgid

#define proc_getpgid rb_f_notimplement

Definition at line 5209 of file process.c.

## ◆ proc_getpgrp

#define proc_getpgrp rb_f_notimplement

Definition at line 5156 of file process.c.

## ◆ proc_getpriority

#define proc_getpriority rb_f_notimplement

Definition at line 5359 of file process.c.

## ◆ proc_getrlimit

#define proc_getrlimit rb_f_notimplement

Definition at line 5647 of file process.c.

## ◆ proc_getsid

#define proc_getsid rb_f_notimplement

Definition at line 5265 of file process.c.

## ◆ proc_initgroups

#define proc_initgroups rb_f_notimplement

Definition at line 6916 of file process.c.

## ◆ proc_setegid_m

#define proc_setegid_m rb_f_notimplement

Definition at line 7433 of file process.c.

## ◆ proc_seteuid_m

#define proc_seteuid_m rb_f_notimplement

Definition at line 7303 of file process.c.

## ◆ proc_setgid

#define proc_setgid rb_f_notimplement

Definition at line 6733 of file process.c.

## ◆ proc_setgroups

#define proc_setgroups rb_f_notimplement

Definition at line 6885 of file process.c.

## ◆ proc_setmaxgroups

#define proc_setmaxgroups rb_f_notimplement

Definition at line 6968 of file process.c.

## ◆ proc_setpgid

#define proc_setpgid rb_f_notimplement

Definition at line 5234 of file process.c.

## ◆ proc_setpgrp

#define proc_setpgrp rb_f_notimplement

Definition at line 5184 of file process.c.

## ◆ proc_setpriority

#define proc_setpriority rb_f_notimplement

Definition at line 5390 of file process.c.

## ◆ proc_setrlimit

#define proc_setrlimit rb_f_notimplement

Definition at line 5723 of file process.c.

## ◆ proc_setsid

#define proc_setsid rb_f_notimplement

Definition at line 5323 of file process.c.

## ◆ proc_setuid

#define proc_setuid rb_f_notimplement

Definition at line 6331 of file process.c.

## ◆ PST2INT

#define PST2INT | ( |  | st | ) | pst_status(st)

Definition at line 704 of file process.c.

## ◆ rb_f_fork

#define rb_f_fork rb_f_notimplement

Definition at line 4361 of file process.c.

## ◆ rb_proc_times

#define rb_proc_times rb_f_notimplement

Definition at line 7908 of file process.c.

## ◆ redirect_cloexec_dup

#define redirect_cloexec_dup | ( |  | oldfd | ) | rb_cloexec_dup(oldfd)

Definition at line 464 of file process.c.

## ◆ redirect_cloexec_dup2

#define redirect_cloexec_dup2 | ( |  | oldfd,
|  |  | newfd
| ) |  | rb_cloexec_dup2((oldfd), (newfd))

Definition at line 465 of file process.c.

## ◆ redirect_close

#define redirect_close | ( |  | fd | ) | close_unless_reserved(fd)

Definition at line 466 of file process.c.

## ◆ redirect_dup

#define redirect_dup | ( |  | oldfd | ) | dup(oldfd)

Definition at line 462 of file process.c.

## ◆ redirect_dup2

#define redirect_dup2 | ( |  | oldfd,
|  |  | newfd
| ) |  | dup2((oldfd), (newfd))

Definition at line 463 of file process.c.

## ◆ RUBY_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID

#define RUBY_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID ID2SYM(id_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID)

## ◆ ruby_nocldwait

#define ruby_nocldwait 0

Definition at line 1152 of file process.c.

## ◆ RUBY_TIME_BASED_CLOCK_REALTIME

#define RUBY_TIME_BASED_CLOCK_REALTIME ID2SYM(id_TIME_BASED_CLOCK_REALTIME)

## ◆ TIMETICK_INT2NUM

#define TIMETICK_INT2NUM | ( |  | v | ) | LONG2NUM(v)

Definition at line 7921 of file process.c.

## ◆ TIMETICK_INT_MAX

#define TIMETICK_INT_MAX LONG_MAX

Definition at line 7920 of file process.c.

## ◆ TIMETICK_INT_MIN

#define TIMETICK_INT_MIN LONG_MIN

Definition at line 7919 of file process.c.

## ◆ TO_BOOL

#define TO_BOOL | ( |  | val,
|  |  | name
| ) |  | NIL_P(val) ? 0 : rb_bool_expected((val), name)

Definition at line 2238 of file process.c.

## ◆ try_with_sh

#define try_with_sh | ( |  | err,
|  |  | prog,
|  |  | argv,
|  |  | envp
| ) |  | (void)0

Definition at line 1819 of file process.c.

## ◆ USE_SPAWNV

#define USE_SPAWNV 0

Definition at line 1960 of file process.c.

## ◆ WAITPID_LOCK_ONLY

#define WAITPID_LOCK_ONLY ((struct waitpid_state *)-1)

Definition at line 1068 of file process.c.

## ◆ WEXITSTATUS

#define WEXITSTATUS | ( |  | w | ) | (((w) >> 8) & 0xff)

Definition at line 140 of file process.c.

## ◆ WIFEXITED

#define WIFEXITED | ( |  | w | ) | (((w) & 0xff) == 0)

Definition at line 131 of file process.c.

## ◆ WIFSIGNALED

#define WIFSIGNALED | ( |  | w | ) | (((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f))

Definition at line 134 of file process.c.

## ◆ WRITE_CONST

#define WRITE_CONST | ( |  | fd,
|  |  | str
| ) |  | (void)(write((fd),(str),sizeof(str)-1)<0)

Definition at line 1728 of file process.c.

## ◆ WSTOPSIG

#define WSTOPSIG WEXITSTATUS

Definition at line 146 of file process.c.

## ◆ WTERMSIG

#define WTERMSIG | ( |  | w | ) | ((w) & 0x7f)

Definition at line 143 of file process.c.

## Typedef Documentation

## ◆ sig_t

typedef void(* sig_t) (int)

Definition at line 307 of file process.c.

## ◆ timetick_int_t

typedef long timetick_int_t

Definition at line 7918 of file process.c.

## ◆ unsigned_clock_t

typedef unsigned int unsigned_clock_t

Definition at line 300 of file process.c.

## Function Documentation

## ◆ Init_process()

void Init_process | ( | void |  | ) |

Definition at line 9051 of file process.c.

References id_in, and InitVM.

## ◆ InitVM_process()

void InitVM_process | ( | void |  | ) |

Definition at line 8620 of file process.c.

References CLASS_OF, CLOCK_MONOTONIC, CLOCK_REALTIME, getegid(), geteuid(), inf(), INT2FIX, NULL, p_gid_from_name, p_sys_issetugid, p_sys_setegid, p_sys_seteuid, p_sys_setgid, p_sys_setregid, p_sys_setresgid, p_sys_setresuid, p_sys_setreuid, p_sys_setrgid, p_sys_setruid, p_sys_setuid, p_uid_from_name, proc_daemon, proc_getgroups, proc_getmaxgroups, proc_getpgid, proc_getpgrp, proc_getpriority, proc_getrlimit, proc_getsid, proc_initgroups, proc_setegid_m, proc_seteuid_m, proc_setgid, proc_setgroups, proc_setmaxgroups, proc_setpgid, proc_setpgrp, proc_setpriority, proc_setrlimit, proc_setsid, proc_setuid, rb_cObject, rb_cThread, rb_define_alias(), rb_define_alloc_func(), rb_define_class_under(), rb_define_const(), rb_define_global_function, rb_define_method, rb_define_module(), rb_define_module_function, rb_define_module_under(), rb_define_singleton_method, ruby::backward::cxxanyargs::rb_define_virtual_variable(), rb_f_fork, rb_gvar_ractor_local(), rb_marshal_define_compat(), rb_mProcess, rb_proc_times, rb_process_status_waitv(), rb_singleton_class(), rb_struct_define_under(), rb_undef_alloc_func(), rb_undef_method(), and WNOHANG.

## ◆ rb_detach_process()

VALUE rb_detach_process | ( | rb_pid_t | pid | ) |

Definition at line 1646 of file process.c.

References rb_process_status::pid, PIDT2NUM, ruby::backward::cxxanyargs::rb_thread_create(), and rb_thread_local_aset().

## ◆ rb_exec_async_signal_safe()

int rb_exec_async_signal_safe | ( | const struct rb_execarg * | eargp,
|  | char * | errmsg,
|  | size_t | errmsg_buflen
| ) |  |

Definition at line 3751 of file process.c.

## ◆ rb_execarg_addopt()

int rb_execarg_addopt | ( | VALUE | execarg_obj,
|  | VALUE | key,
|  | VALUE | val
| ) |  |

Definition at line 2240 of file process.c.

References rb_execarg::chdir_dir, rb_execarg::chdir_given, rb_execarg::close_others_do, rb_execarg::close_others_given, rb_execarg::exception_given, EXPORT_DUP, FilePathValue, rb_execarg::gid, rb_execarg::gid_given, id, id_exception, id_in, INT2FIX, key, mode_t, rb_execarg::new_pgroup_flag, rb_execarg::new_pgroup_given, NUM2MODET, NUM2PIDT, OBJ2GID, OBJ2UID, rb_execarg::pgroup_given, rb_execarg::pgroup_pgid, Qtrue, rb_check_id(), rb_eArgError, rb_eNotImpError, rb_execarg_get(), RB_GC_GUARD, rb_raise(), rb_str_encode_ospath(), RTEST, ST_CONTINUE, ST_STOP, T_ARRAY, T_FILE, T_FIXNUM, T_SYMBOL, TO_BOOL, TYPE, rb_execarg::uid, rb_execarg::uid_given, rb_execarg::umask_given, rb_execarg::umask_mask, rb_execarg::unsetenv_others_do, and rb_execarg::unsetenv_others_given.

## ◆ rb_execarg_commandline()

char * rb_execarg_commandline | ( | const struct rb_execarg * | eargp,
|  | VALUE * | prog
| ) |  |

Definition at line 4548 of file process.c.

References argc, argv, rb_execarg::argv_buf, rb_execarg::argv_str, rb_execarg::cmd, rb_execarg::invoke, prog, rb_str_new, RSTRING_LEN, RSTRING_PTR, str, StringValueCStr, and rb_execarg::use_shell.

## ◆ rb_execarg_extract_options()

VALUE rb_execarg_extract_options | ( | VALUE | execarg_obj,
|  | VALUE | opthash
| ) |  |

Definition at line 2506 of file process.c.

References Qnil, rb_hash_stlike_foreach(), and RHASH_EMPTY_P.

Referenced by rb_io_popen().

## ◆ rb_execarg_get()

struct rb_execarg * rb_execarg_get | ( | VALUE | execarg_obj | ) |

Definition at line 2837 of file process.c.

References TypedData_Get_Struct.

Referenced by rb_execarg_addopt(), rb_execarg_setenv(), and rb_f_exec().

## ◆ rb_execarg_new()

VALUE rb_execarg_new | ( | int | argc,
|  | const VALUE * | argv,
|  | int | accept_shell,
|  | int | allow_exc_opt
| ) |  |

Definition at line 2862 of file process.c.

References argc, argv, rb_execarg::exception_given, rb_eArgError, rb_raise(), and TypedData_Make_Struct.

Referenced by rb_f_exec(), and rb_io_popen().

## ◆ rb_execarg_parent_end()

void rb_execarg_parent_end | ( | VALUE | execarg_obj | ) |

Definition at line 3082 of file process.c.

References RB_GC_GUARD.

Referenced by rb_execarg_parent_start().

## ◆ rb_execarg_parent_start()

void rb_execarg_parent_start | ( | VALUE | execarg_obj | ) |

Definition at line 3043 of file process.c.

References rb_execarg_parent_end(), rb_jump_tag(), and rb_protect().

## ◆ rb_execarg_run_options()

int rb_execarg_run_options | ( | const struct rb_execarg * | eargp,
|  | struct rb_execarg * | sargp,
|  | char * | errmsg,
|  | size_t | errmsg_buflen
| ) |  |

Definition at line 3622 of file process.c.

References rb_execarg::chdir_dir, rb_execarg::chdir_given, rb_execarg::close_others_do, rb_execarg::close_others_maxhint, rb_execarg::dup2_tmpbuf, rb_execarg::env_modification, ERRMSG, rb_execarg::fd_close, rb_execarg::fd_dup2, rb_execarg::fd_dup2_child, rb_execarg::gid, rb_execarg::gid_given, key, mask, MEMZERO, mode_t, NIL_P, rb_execarg::pgroup_given, Qfalse, Qnil, RARRAY_AREF, RARRAY_LEN, rb_close_before_exec(), rb_dir_getwd_ospath(), rb_env_clear(), rb_warn(), rb_execarg::redirect_fds, rb_execarg::rlimit_limits, RSTRING_PTR, ruby_setenv(), setgid(), setuid(), StringValueCStr, rb_execarg::uid, rb_execarg::uid_given, rb_execarg::umask_given, rb_execarg::umask_mask, rb_execarg::unsetenv_others_do, and rb_execarg::unsetenv_others_given.

## ◆ rb_execarg_setenv()

void rb_execarg_setenv | ( | VALUE | execarg_obj,
|  | VALUE | env
| ) |  |

Definition at line 2875 of file process.c.

References env, rb_execarg::env_modification, NIL_P, rb_execarg::path_env, Qfalse, and rb_execarg_get().

Referenced by rb_io_popen().

## ◆ rb_exit()

void rb_exit | ( | int | status | ) |

Definition at line 4416 of file process.c.

References INT2NUM, rb_class_new_instance(), rb_eSystemExit, rb_exc_raise(), rb_str_new2, and ruby_stop().

Referenced by rb_f_abort(), rb_f_exit(), and rb_thread_kill().

## ◆ rb_f_abort()

VALUE rb_f_abort | ( | int | argc,
|  | const VALUE * | argv
| ) |  |

Definition at line 4494 of file process.c.

References argc, argv, EXIT_FAILURE, INT2NUM, NIL_P, Qnil, rb_check_arity, rb_class_new_instance(), rb_ec_error_print(), rb_ec_get_errinfo(), rb_eSystemExit, rb_exc_raise(), rb_exit(), rb_io_puts(), rb_ractor_stderr(), StringValue, and UNREACHABLE_RETURN.

## ◆ rb_f_exec()

VALUE rb_f_exec | ( | int | argc,
|  | const VALUE * | argv
| ) |  |

Definition at line 3109 of file process.c.

References argc, argv, CHILD_ERRMSG_BUFLEN, rb_execarg::cmd, rb_execarg::command_name, err, FALSE, rb_execarg::invoke, mjit_enabled, Qnil, rb_execarg_get(), rb_execarg_new(), RB_GC_GUARD, rb_jump_tag(), rb_protect(), rb_syserr_fail_str(), rb_execarg::sh, rb_execarg::shell_script, TRUE, UNREACHABLE_RETURN, and rb_execarg::use_shell.

## ◆ rb_f_exit()

VALUE rb_f_exit | ( | int | argc,
|  | const VALUE * | argv
| ) |  |

Definition at line 4429 of file process.c.

References argc, argv, EXIT_SUCCESS, Qnil, rb_check_arity, rb_exit(), and UNREACHABLE_RETURN.

## ◆ rb_last_status_clear()

void rb_last_status_clear | ( | void |  | ) |

Definition at line 666 of file process.c.

References Qnil.

## ◆ rb_last_status_get()

VALUE rb_last_status_get | ( | void |  | ) |

Definition at line 596 of file process.c.

## ◆ rb_last_status_set()

void rb_last_status_set | ( | int | status,
|  | rb_pid_t | pid
| ) |  |

Definition at line 660 of file process.c.

References rb_process_status::pid, rb_process_status_new(), and rb_process_status::status.

## ◆ rb_native_cond_signal()

void rb_native_cond_signal | ( | rb_nativethread_cond_t * |  | ) |

## ◆ rb_native_cond_wait()

void rb_native_cond_wait | ( | rb_nativethread_cond_t * | ,
|  | rb_nativethread_lock_t * |
| ) |  |

Referenced by ruby_waitpid_locked().

## ◆ rb_native_mutex_lock()

void rb_native_mutex_lock | ( | rb_nativethread_lock_t * |  | ) |

Referenced by rb_sigwait_fd_migrate(), ruby_waitpid_all(), and ruby_waitpid_locked().

## ◆ rb_native_mutex_unlock()

void rb_native_mutex_unlock | ( | rb_nativethread_lock_t * |  | ) |

Referenced by rb_sigwait_fd_migrate(), ruby_waitpid_all(), and ruby_waitpid_locked().

## ◆ rb_proc_exec()

int rb_proc_exec | ( | const char * | str | ) |

Definition at line 1891 of file process.c.

References Qfalse, and str.

## ◆ rb_process_status_new()

VALUE rb_process_status_new | ( | rb_pid_t | pid,
|  | int | status,
|  | int | error
| ) |  |

Definition at line 623 of file process.c.

References error(), rb_process_status::error, rb_process_status::pid, rb_obj_freeze(), RTYPEDDATA_DATA, and rb_process_status::status.

Referenced by rb_last_status_set(), and rb_process_status_wait().

## ◆ rb_process_status_wait()

VALUE rb_process_status_wait | ( | rb_pid_t | pid,
|  | int | flags
| ) |  |

Definition at line 1344 of file process.c.

References COROUTINE_STACK_FREE, COROUTINE_STACK_LOCAL, waitpid_state::ec, waitpid_state::errnum, waitpid_state::pid, Qnil, rb_process_status_new(), rb_scheduler_current(), rb_scheduler_process_wait(), rb_scheduler_supports_process_wait(), waitpid_state::ret, ruby_nocldwait, waitpid_state::status, WAITPID_USE_SIGCHLD, and WNOHANG.

Referenced by rb_process_status_waitv(), and rb_waitpid().

## ◆ rb_process_status_waitv()

VALUE rb_process_status_waitv | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | _
| ) |  |

Definition at line 1424 of file process.c.

References argc, argv, NUM2PIDT, waitpid_state::pid, rb_check_arity, RB_NUM2INT, and rb_process_status_wait().

Referenced by InitVM_process().

## ◆ rb_sigwait_fd_get()

int rb_sigwait_fd_get | ( | const rb_thread_t * |  | ) |

Referenced by rb_thread_fd_select(), rb_threadptr_execute_interrupts(), and ruby_waitpid_locked().

## ◆ rb_sigwait_fd_migrate()

void rb_sigwait_fd_migrate | ( | rb_vm_t * | vm | ) |

Definition at line 1125 of file process.c.

References rb_native_mutex_lock(), rb_native_mutex_unlock(), and rb_vm_struct::waitpid_lock.

Referenced by rb_threadptr_execute_interrupts().

## ◆ rb_sigwait_fd_put()

void rb_sigwait_fd_put | ( | const rb_thread_t * | ,
|  | int | fd
| ) |  |

Referenced by rb_threadptr_execute_interrupts(), and ruby_waitpid_locked().

## ◆ rb_sigwait_sleep()

void rb_sigwait_sleep | ( | const rb_thread_t * | ,
|  | int | fd,
|  | const rb_hrtime_t * |
| ) |  |

Referenced by ruby_waitpid_locked().

## ◆ rb_spawn()

rb_pid_t rb_spawn | ( | int | argc,
|  | const VALUE * | argv
| ) |  |

Definition at line 4676 of file process.c.

References argc, argv, and NULL.

## ◆ rb_spawn_err()

rb_pid_t rb_spawn_err | ( | int | argc,
|  | const VALUE * | argv,
|  | char * | errmsg,
|  | size_t | errmsg_buflen
| ) |  |

Definition at line 4670 of file process.c.

References argc, and argv.

## ◆ rb_syswait()

void rb_syswait | ( | rb_pid_t | pid | ) |

Definition at line 4539 of file process.c.

References rb_waitpid().

## ◆ rb_thread_sleep_interruptible()

void rb_thread_sleep_interruptible | ( | void |  | ) |

Definition at line 1538 of file thread.c.

References rb_thread_struct::ec, RUBY_VM_CHECK_INTS_BLOCKING, and THREAD_STOPPED.

## ◆ rb_waitpid()

rb_pid_t rb_waitpid | ( | rb_pid_t | pid,
|  | int * | st,
|  | int | flags
| ) |  |

Definition at line 1443 of file process.c.

References rb_process_status::error, NIL_P, rb_process_status::pid, waitpid_state::pid, rb_process_status_wait(), RTYPEDDATA_DATA, rb_process_status::status, and waitpid_state::status.

Referenced by rb_syswait().

## ◆ ruby_waitpid_all()

void ruby_waitpid_all | ( | rb_vm_t * | vm | ) |

Definition at line 1156 of file process.c.

References rb_native_mutex_lock(), rb_native_mutex_unlock(), ruby_nocldwait, rb_vm_struct::waiting_grps, rb_vm_struct::waiting_pids, rb_vm_struct::waitpid_lock, and WNOHANG.

Referenced by ruby_sigchld_handler().

## ◆ ruby_waitpid_locked()

rb_pid_t ruby_waitpid_locked | ( | rb_vm_t * | vm,
|  | rb_pid_t | pid,
|  | int * | status,
|  | int | options,
|  | rb_nativethread_cond_t * | cond
| ) |  |

Definition at line 1198 of file process.c.

References assert, waitpid_state::cond, waitpid_state::ec, waitpid_state::errnum, waitpid_state::options, waitpid_state::pid, rb_native_cond_wait(), rb_native_mutex_lock(), rb_native_mutex_unlock(), rb_sigwait_fd_get(), rb_sigwait_fd_put(), rb_sigwait_sleep(), waitpid_state::ret, ruby_thread_has_gvl_p(), waitpid_state::status, rb_vm_struct::waiting_grps, rb_vm_struct::waiting_pids, rb_vm_struct::waitpid_lock, waitpid_state::wnode, and WNOHANG.

## Variable Documentation

## ◆ rb_mProcess

VALUE rb_mProcess

Definition at line 8608 of file process.c.

Referenced by InitVM_process(), and ruby_prog_init().