Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)
|
#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 |
Typedefs | |
typedef unsigned int | unsigned_clock_t |
typedef void(* | sig_t) (int) |
typedef long | timetick_int_t |
Variables | |
VALUE | rb_mProcess |
#define CHILD_ERRMSG_BUFLEN 80 |
#define EXPORT_DUP | ( | str | ) | rb_str_dup(str) |
#define MUL_OVERFLOW_TIMETICK_P | ( | a, | |
b | |||
) | MUL_OVERFLOW_LONG_P(a, b) |
#define p_gid_from_name rb_f_notimplement |
#define p_sys_issetugid rb_f_notimplement |
#define p_sys_setegid rb_f_notimplement |
#define p_sys_seteuid rb_f_notimplement |
#define p_sys_setgid rb_f_notimplement |
#define p_sys_setregid rb_f_notimplement |
#define p_sys_setresgid rb_f_notimplement |
#define p_sys_setresuid rb_f_notimplement |
#define p_sys_setreuid rb_f_notimplement |
#define p_sys_setrgid rb_f_notimplement |
#define p_sys_setruid rb_f_notimplement |
#define p_sys_setuid rb_f_notimplement |
#define p_uid_from_name rb_f_notimplement |
#define parent_redirect_close | ( | fd | ) | close_unless_reserved(fd) |
#define parent_redirect_open | ( | pathname, | |
flags, | |||
perm | |||
) | rb_cloexec_open((pathname), (flags), (perm)) |
#define proc_daemon rb_f_notimplement |
#define proc_getgroups rb_f_notimplement |
#define proc_getmaxgroups rb_f_notimplement |
#define proc_getpgid rb_f_notimplement |
#define proc_getpgrp rb_f_notimplement |
#define proc_getpriority rb_f_notimplement |
#define proc_getrlimit rb_f_notimplement |
#define proc_getsid rb_f_notimplement |
#define proc_initgroups rb_f_notimplement |
#define proc_setegid_m rb_f_notimplement |
#define proc_seteuid_m rb_f_notimplement |
#define proc_setgid rb_f_notimplement |
#define proc_setgroups rb_f_notimplement |
#define proc_setmaxgroups rb_f_notimplement |
#define proc_setpgid rb_f_notimplement |
#define proc_setpgrp rb_f_notimplement |
#define proc_setpriority rb_f_notimplement |
#define proc_setrlimit rb_f_notimplement |
#define proc_setsid rb_f_notimplement |
#define proc_setuid rb_f_notimplement |
#define rb_f_fork rb_f_notimplement |
#define rb_proc_times rb_f_notimplement |
#define redirect_cloexec_dup | ( | oldfd | ) | rb_cloexec_dup(oldfd) |
#define redirect_cloexec_dup2 | ( | oldfd, | |
newfd | |||
) | rb_cloexec_dup2((oldfd), (newfd)) |
#define redirect_dup2 | ( | oldfd, | |
newfd | |||
) | dup2((oldfd), (newfd)) |
#define RUBY_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID ID2SYM(id_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID) |
#define RUBY_TIME_BASED_CLOCK_REALTIME ID2SYM(id_TIME_BASED_CLOCK_REALTIME) |
#define TO_BOOL | ( | val, | |
name | |||
) | NIL_P(val) ? 0 : rb_bool_expected((val), name) |
#define WAITPID_LOCK_ONLY ((struct waitpid_state *)-1) |
#define WIFSIGNALED | ( | w | ) | (((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f)) |
#define WSTOPSIG WEXITSTATUS |
typedef long timetick_int_t |
typedef unsigned int unsigned_clock_t |
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.
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().
int rb_exec_async_signal_safe | ( | const struct rb_execarg * | eargp, |
char * | errmsg, | ||
size_t | errmsg_buflen | ||
) |
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.
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.
Definition at line 2506 of file process.c.
References Qnil, rb_hash_stlike_foreach(), and RHASH_EMPTY_P.
Referenced by rb_io_popen().
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().
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().
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().
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().
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.
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().
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().
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.
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.
Definition at line 4429 of file process.c.
References argc, argv, EXIT_SUCCESS, Qnil, rb_check_arity, rb_exit(), and UNREACHABLE_RETURN.
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.
void rb_native_cond_signal | ( | rb_nativethread_cond_t * | ) |
void rb_native_cond_wait | ( | rb_nativethread_cond_t * | , |
rb_nativethread_lock_t * | |||
) |
Referenced by ruby_waitpid_locked().
void rb_native_mutex_lock | ( | rb_nativethread_lock_t * | ) |
Referenced by rb_sigwait_fd_migrate(), ruby_waitpid_all(), and ruby_waitpid_locked().
void rb_native_mutex_unlock | ( | rb_nativethread_lock_t * | ) |
Referenced by rb_sigwait_fd_migrate(), ruby_waitpid_all(), and ruby_waitpid_locked().
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().
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().
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().
int rb_sigwait_fd_get | ( | const rb_thread_t * | ) |
Referenced by rb_thread_fd_select(), rb_threadptr_execute_interrupts(), and ruby_waitpid_locked().
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().
void rb_sigwait_fd_put | ( | const rb_thread_t * | , |
int | fd | ||
) |
Referenced by rb_threadptr_execute_interrupts(), and ruby_waitpid_locked().
void rb_sigwait_sleep | ( | const rb_thread_t * | , |
int | fd, | ||
const rb_hrtime_t * | |||
) |
Referenced by ruby_waitpid_locked().
void rb_syswait | ( | rb_pid_t | pid | ) |
Definition at line 4539 of file process.c.
References rb_waitpid().
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.
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().
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().
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.
VALUE rb_mProcess |
Definition at line 8608 of file process.c.
Referenced by InitVM_process(), and ruby_prog_init().