Ruby  2.4.2p198(2017-09-14revision59899)
Data Structures | Macros | Typedefs | Functions | Variables
process.c File Reference
#include "internal.h"
#include "ruby/io.h"
#include "ruby/thread.h"
#include "ruby/util.h"
#include "vm_core.h"
#include <stdio.h>
#include <errno.h>
#include <signal.h>
#include <time.h>
#include <ctype.h>
#include "ruby/st.h"
#include <sys/stat.h>
#include "dln.h"
Include dependency graph for process.c:

Go to the source code of this file.

Data Structures

struct  waitpid_arg
 
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 WIFSTOPPED(w)   (((w) & 0xff) == 0x7f)
 
#define WEXITSTATUS(w)   (((w) >> 8) & 0xff)
 
#define WTERMSIG(w)   ((w) & 0x7f)
 
#define WSTOPSIG   WEXITSTATUS
 
#define preserving_errno(stmts)   do {int saved_errno = errno; stmts; errno = saved_errno;} while (0)
 
#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_status   ruby_static_id_status
 
#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)   NUM2INT(pst_to_i(st))
 
#define before_fork_ruby()   before_exec()
 
#define after_fork_ruby()   (rb_threadptr_pending_interrupt_clear(GET_THREAD()), after_exec())
 
#define try_with_sh(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 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 NDIV(x, y)   (-(-((x)+1)/(y))-1)
 
#define DIV(n, d)   ((n)<0 ? NDIV((n),(d)) : (n)/(d))
 
#define RUBY_GETTIMEOFDAY_BASED_CLOCK_REALTIME   ID2SYM(id_GETTIMEOFDAY_BASED_CLOCK_REALTIME)
 
#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)
 
#define rb_intern(str)   rb_intern_const(str)
 

Typedefs

typedef unsigned int unsigned_clock_t
 
typedef void(* sig_t) (int)
 
typedef long timetick_int_t
 

Functions

static void check_uid_switch (void)
 
static void check_gid_switch (void)
 
static int close_unless_reserved (int fd)
 
static VALUE get_pid (void)
 
static VALUE get_ppid (void)
 
VALUE rb_last_status_get (void)
 
void rb_last_status_set (int status, rb_pid_t pid)
 
void rb_last_status_clear (void)
 
static VALUE pst_to_i (VALUE st)
 
static VALUE pst_pid (VALUE st)
 
static void pst_message (VALUE str, rb_pid_t pid, int status)
 
static VALUE pst_to_s (VALUE st)
 
static VALUE pst_inspect (VALUE st)
 
static VALUE pst_equal (VALUE st1, VALUE st2)
 
static VALUE pst_bitand (VALUE st1, VALUE st2)
 
static VALUE pst_rshift (VALUE st1, VALUE st2)
 
static VALUE pst_wifstopped (VALUE st)
 
static VALUE pst_wstopsig (VALUE st)
 
static VALUE pst_wifsignaled (VALUE st)
 
static VALUE pst_wtermsig (VALUE st)
 
static VALUE pst_wifexited (VALUE st)
 
static VALUE pst_wexitstatus (VALUE st)
 
static VALUE pst_success_p (VALUE st)
 
static VALUE pst_wcoredump (VALUE st)
 
static rb_pid_t do_waitpid (rb_pid_t pid, int *st, int flags)
 
static void * rb_waitpid_blocking (void *data)
 
static rb_pid_t do_waitpid_nonblocking (rb_pid_t pid, int *st, int flags)
 
rb_pid_t rb_waitpid (rb_pid_t pid, int *st, int flags)
 
static VALUE proc_wait (int argc, VALUE *argv)
 
static VALUE proc_wait2 (int argc, VALUE *argv)
 
static VALUE proc_waitall (void)
 
static VALUE detach_process_pid (VALUE thread)
 
static VALUE detach_process_watcher (void *arg)
 
VALUE rb_detach_process (rb_pid_t pid)
 
static VALUE proc_detach (VALUE obj, VALUE pid)
 
static void before_exec_async_signal_safe (void)
 
static void before_exec_non_async_signal_safe (void)
 
static void before_exec (void)
 
static void after_exec_async_signal_safe (void)
 
static void after_exec_non_async_signal_safe (void)
 
static void after_exec (void)
 
static void security (const char *str)
 
static int proc_exec_cmd (const char *prog, VALUE argv_str, VALUE envp_str)
 
static int proc_exec_sh (const char *str, VALUE envp_str)
 
int rb_proc_exec (const char *str)
 
static void mark_exec_arg (void *ptr)
 
static size_t memsize_exec_arg (const void *ptr)
 
static VALUE hide_obj (VALUE obj)
 
static VALUE check_exec_redirect_fd (VALUE v, int iskey)
 
static VALUE check_exec_redirect1 (VALUE ary, VALUE key, VALUE param)
 
static void check_exec_redirect (VALUE key, VALUE val, struct rb_execarg *eargp)
 
int rb_execarg_addopt (VALUE execarg_obj, VALUE key, VALUE val)
 
static int check_exec_options_i (st_data_t st_key, st_data_t st_val, st_data_t arg)
 
static int check_exec_options_i_extract (st_data_t st_key, st_data_t st_val, st_data_t arg)
 
static int check_exec_fds_1 (struct rb_execarg *eargp, VALUE h, int maxhint, VALUE ary)
 
static VALUE check_exec_fds (struct rb_execarg *eargp)
 
static void rb_check_exec_options (VALUE opthash, VALUE execarg_obj)
 
VALUE rb_execarg_extract_options (VALUE execarg_obj, VALUE opthash)
 
static int check_exec_env_i (st_data_t st_key, st_data_t st_val, st_data_t arg)
 
static VALUE rb_check_exec_env (VALUE hash, VALUE *path)
 
static VALUE rb_check_argv (int argc, VALUE *argv)
 
static VALUE check_hash (VALUE obj)
 
static VALUE rb_exec_getargs (int *argc_p, VALUE **argv_p, int accept_shell, VALUE *env_ret, VALUE *opthash_ret)
 
static int compare_posix_sh (const void *key, const void *el)
 
static void rb_exec_fillarg (VALUE prog, int argc, VALUE *argv, VALUE env, VALUE opthash, VALUE execarg_obj)
 
VALUE rb_execarg_new (int argc, const VALUE *argv, int accept_shell)
 
struct rb_execargrb_execarg_get (VALUE execarg_obj)
 
VALUE rb_execarg_init (int argc, const VALUE *orig_argv, int accept_shell, VALUE execarg_obj)
 
void rb_execarg_setenv (VALUE execarg_obj, VALUE env)
 
static int fill_envp_buf_i (st_data_t st_key, st_data_t st_val, st_data_t arg)
 
static long run_exec_dup2_tmpbuf_size (long n)
 
static void * open_func (void *ptr)
 
static VALUE rb_execarg_parent_start1 (VALUE execarg_obj)
 
void rb_execarg_parent_start (VALUE execarg_obj)
 
static VALUE execarg_parent_end (VALUE execarg_obj)
 
void rb_execarg_parent_end (VALUE execarg_obj)
 
static void rb_exec_fail (struct rb_execarg *eargp, int err, const char *errmsg)
 
VALUE rb_f_exec (int argc, const VALUE *argv)
 
static int fd_get_cloexec (int fd, char *errmsg, size_t errmsg_buflen)
 
static int fd_set_cloexec (int fd, char *errmsg, size_t errmsg_buflen)
 
static int fd_clear_cloexec (int fd, char *errmsg, size_t errmsg_buflen)
 
static int save_redirect_fd (int fd, struct rb_execarg *sargp, char *errmsg, size_t errmsg_buflen)
 
static int intcmp (const void *a, const void *b)
 
static int intrcmp (const void *a, const void *b)
 
static int run_exec_dup2 (VALUE ary, VALUE tmpbuf, struct rb_execarg *sargp, char *errmsg, size_t errmsg_buflen)
 
static int run_exec_close (VALUE ary, char *errmsg, size_t errmsg_buflen)
 
static int run_exec_dup2_child (VALUE ary, struct rb_execarg *sargp, char *errmsg, size_t errmsg_buflen)
 
static VALUE save_env_i (RB_BLOCK_CALL_FUNC_ARGLIST(i, ary))
 
static void save_env (struct rb_execarg *sargp)
 
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)
 
static int exit_status_code (VALUE status)
 
static VALUE rb_f_exit_bang (int argc, VALUE *argv, VALUE obj)
 
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)
 
static rb_pid_t rb_spawn_process (struct rb_execarg *eargp, char *errmsg, size_t errmsg_buflen)
 
static VALUE do_spawn_process (VALUE arg)
 
static rb_pid_t rb_execarg_spawn (VALUE execarg_obj, char *errmsg, size_t errmsg_buflen)
 
static rb_pid_t rb_spawn_internal (int argc, const VALUE *argv, char *errmsg, size_t errmsg_buflen)
 
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)
 
static VALUE rb_f_system (int argc, VALUE *argv)
 
static VALUE rb_f_spawn (int argc, VALUE *argv)
 
static VALUE rb_f_sleep (int argc, VALUE *argv)
 
static VALUE proc_getuid (VALUE obj)
 
static VALUE p_uid_change_privilege (VALUE obj, VALUE id)
 
static VALUE proc_getgid (VALUE obj)
 
static VALUE p_gid_change_privilege (VALUE obj, VALUE id)
 
static VALUE proc_geteuid (VALUE obj)
 
static rb_uid_t rb_seteuid_core (rb_uid_t euid)
 
static VALUE p_uid_grant_privilege (VALUE obj, VALUE id)
 
static VALUE proc_getegid (VALUE obj)
 
static rb_gid_t rb_setegid_core (rb_gid_t egid)
 
static VALUE p_gid_grant_privilege (VALUE obj, VALUE id)
 
static VALUE p_uid_exchangeable (void)
 
static VALUE p_uid_exchange (VALUE obj)
 
static VALUE p_gid_exchangeable (void)
 
static VALUE p_gid_exchange (VALUE obj)
 
static VALUE p_uid_have_saved_id (void)
 
static VALUE p_uid_sw_ensure (VALUE obj)
 
static VALUE p_uid_switch (VALUE obj)
 
static VALUE p_gid_have_saved_id (void)
 
static VALUE p_gid_sw_ensure (VALUE obj)
 
static VALUE p_gid_switch (VALUE obj)
 
 CONSTFUNC (static timetick_int_t gcd_timetick_int(timetick_int_t, timetick_int_t))
 
static timetick_int_t gcd_timetick_int (timetick_int_t a, timetick_int_t b)
 
static void reduce_fraction (timetick_int_t *np, timetick_int_t *dp)
 
static void reduce_factors (timetick_int_t *numerators, int num_numerators, timetick_int_t *denominators, int num_denominators)
 
static VALUE timetick2dblnum (struct timetick *ttp, timetick_int_t *numerators, int num_numerators, timetick_int_t *denominators, int num_denominators)
 
static VALUE timetick2dblnum_reciprocal (struct timetick *ttp, timetick_int_t *numerators, int num_numerators, timetick_int_t *denominators, int num_denominators)
 
static VALUE timetick2integer (struct timetick *ttp, timetick_int_t *numerators, int num_numerators, timetick_int_t *denominators, int num_denominators)
 
static VALUE make_clock_result (struct timetick *ttp, timetick_int_t *numerators, int num_numerators, timetick_int_t *denominators, int num_denominators, VALUE unit)
 
VALUE rb_clock_gettime (int argc, VALUE *argv)
 
VALUE rb_clock_getres (int argc, VALUE *argv)
 
void InitVM_process (void)
 
void Init_process (void)
 

Variables

static ID id_in
 
static ID id_out
 
static ID id_err
 
static ID id_pid
 
static ID id_uid
 
static ID id_gid
 
static ID id_close
 
static ID id_child
 
static ID id_unsetenv_others
 
static ID id_chdir
 
static ID id_umask
 
static ID id_close_others
 
static ID id_ENV
 
static ID id_nanosecond
 
static ID id_microsecond
 
static ID id_millisecond
 
static ID id_second
 
static ID id_float_microsecond
 
static ID id_float_millisecond
 
static ID id_float_second
 
static ID id_GETTIMEOFDAY_BASED_CLOCK_REALTIME
 
static ID id_TIME_BASED_CLOCK_REALTIME
 
static ID id_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID
 
static ID id_hertz
 
ID ruby_static_id_status
 
static VALUE rb_cProcessStatus
 
static VALUE rb_cWaiter
 
static const rb_data_type_t exec_arg_data_type
 
static int under_uid_switch = 0
 
static int under_gid_switch = 0
 
static rb_uid_t SAVED_USER_ID = -1
 
static rb_gid_t SAVED_GROUP_ID = -1
 
VALUE rb_mProcess
 
VALUE rb_mProcUID
 
VALUE rb_mProcGID
 
VALUE rb_mProcID_Syscall
 

Macro Definition Documentation

◆ after_fork_ruby

#define after_fork_ruby ( )    (rb_threadptr_pending_interrupt_clear(GET_THREAD()), after_exec())

Definition at line 1208 of file process.c.

Referenced by rb_exec_async_signal_safe().

◆ ALWAYS_NEED_ENVP

#define ALWAYS_NEED_ENVP   0

Definition at line 293 of file process.c.

Referenced by rb_execarg_parent_start1().

◆ before_fork_ruby

#define before_fork_ruby ( )    before_exec()

Definition at line 1207 of file process.c.

Referenced by rb_exec_async_signal_safe().

◆ CHILD_ERRMSG_BUFLEN

#define CHILD_ERRMSG_BUFLEN   80

Referenced by rb_f_exec(), and rb_f_spawn().

◆ DIV

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

Definition at line 7046 of file process.c.

Referenced by timetick2integer().

◆ ENVMATCH

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

Definition at line 1942 of file process.c.

Referenced by check_exec_env_i().

◆ ERRMSG

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

◆ ERRMSG1

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

Definition at line 2622 of file process.c.

◆ ERRMSG2

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

Definition at line 2623 of file process.c.

◆ EXIT_FAILURE

#define EXIT_FAILURE   1

Definition at line 43 of file process.c.

Referenced by exit_status_code(), rb_exec_async_signal_safe(), rb_f_abort(), and rb_f_exit_bang().

◆ EXIT_SUCCESS

#define EXIT_SUCCESS   0

◆ EXPORT_DUP

#define EXPORT_DUP (   str)    rb_str_dup(str)

Definition at line 1384 of file process.c.

Referenced by check_exec_redirect(), and rb_execarg_addopt().

◆ EXPORT_STR

#define EXPORT_STR (   str)    (str)

Definition at line 1383 of file process.c.

Referenced by check_exec_env_i(), and rb_exec_fillarg().

◆ FINISH_GETGRNAM

#define FINISH_GETGRNAM   /* do nothing */

Definition at line 240 of file process.c.

◆ FINISH_GETPWNAM

#define FINISH_GETPWNAM   /* do nothing */

Definition at line 197 of file process.c.

◆ id_status

#define id_status   ruby_static_id_status

Definition at line 285 of file process.c.

Referenced by pst_to_i(), and rb_last_status_set().

◆ MAXPATHLEN

#define MAXPATHLEN   1024

Definition at line 59 of file process.c.

Referenced by proc_exec_sh(), and rb_exec_fillarg().

◆ NDIV

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

Definition at line 7045 of file process.c.

◆ OBJ2GID

#define OBJ2GID (   id)    NUM2GIDT(id)

◆ OBJ2GID1

#define OBJ2GID1 (   id)    NUM2GIDT(id)

Definition at line 241 of file process.c.

◆ OBJ2UID

#define OBJ2UID (   id)    NUM2UIDT(id)

◆ OBJ2UID1

#define OBJ2UID1 (   id)    NUM2UIDT(id)

Definition at line 198 of file process.c.

◆ p_gid_from_name [1/2]

#define p_gid_from_name   p_gid_from_name

Definition at line 245 of file process.c.

Referenced by check_gid_switch(), and InitVM_process().

◆ p_gid_from_name [2/2]

#define p_gid_from_name   rb_f_notimplement

Definition at line 245 of file process.c.

◆ P_NOWAIT

#define P_NOWAIT   _P_NOWAIT

Definition at line 1393 of file process.c.

Referenced by check_spawn_mode().

◆ p_sys_issetugid

#define p_sys_issetugid   rb_f_notimplement

Definition at line 5725 of file process.c.

Referenced by InitVM_process().

◆ p_sys_setegid

#define p_sys_setegid   rb_f_notimplement

Definition at line 5639 of file process.c.

Referenced by InitVM_process().

◆ p_sys_seteuid

#define p_sys_seteuid   rb_f_notimplement

Definition at line 5259 of file process.c.

Referenced by InitVM_process().

◆ p_sys_setgid

#define p_sys_setgid   rb_f_notimplement

Definition at line 5595 of file process.c.

Referenced by InitVM_process(), and p_uid_change_privilege().

◆ p_sys_setregid

#define p_sys_setregid   rb_f_notimplement

Definition at line 5668 of file process.c.

Referenced by InitVM_process().

◆ p_sys_setresgid

#define p_sys_setresgid   rb_f_notimplement

Definition at line 5697 of file process.c.

Referenced by InitVM_process().

◆ p_sys_setresuid

#define p_sys_setresuid   rb_f_notimplement

Definition at line 5318 of file process.c.

Referenced by InitVM_process().

◆ p_sys_setreuid

#define p_sys_setreuid   rb_f_notimplement

Definition at line 5288 of file process.c.

Referenced by InitVM_process().

◆ p_sys_setrgid

#define p_sys_setrgid   rb_f_notimplement

Definition at line 5617 of file process.c.

Referenced by InitVM_process().

◆ p_sys_setruid

#define p_sys_setruid   rb_f_notimplement

Definition at line 5237 of file process.c.

Referenced by InitVM_process().

◆ p_sys_setuid

#define p_sys_setuid   rb_f_notimplement

Definition at line 5215 of file process.c.

Referenced by check_gid_switch(), and InitVM_process().

◆ p_uid_from_name [1/2]

#define p_uid_from_name   p_uid_from_name

Definition at line 202 of file process.c.

Referenced by check_gid_switch(), and InitVM_process().

◆ p_uid_from_name [2/2]

#define p_uid_from_name   rb_f_notimplement

Definition at line 202 of file process.c.

◆ parent_redirect_close

#define parent_redirect_close (   fd)    close_unless_reserved(fd)

Definition at line 403 of file process.c.

Referenced by close_unless_reserved(), and execarg_parent_end().

◆ parent_redirect_open

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

Definition at line 402 of file process.c.

Referenced by close_unless_reserved(), and open_func().

◆ PREPARE_GETGRNAM

#define PREPARE_GETGRNAM   /* do nothing */

Definition at line 239 of file process.c.

◆ PREPARE_GETPWNAM

#define PREPARE_GETPWNAM   /* do nothing */

Definition at line 196 of file process.c.

◆ preserving_errno

#define preserving_errno (   stmts)    do {int saved_errno = errno; stmts; errno = saved_errno;} while (0)

Definition at line 153 of file process.c.

Referenced by proc_exec_cmd(), rb_exec_async_signal_safe(), and rb_proc_exec().

◆ proc_daemon

#define proc_daemon   rb_f_notimplement

Definition at line 6082 of file process.c.

Referenced by InitVM_process().

◆ proc_getgroups

#define proc_getgroups   rb_f_notimplement

Definition at line 5873 of file process.c.

Referenced by InitVM_process().

◆ proc_getmaxgroups

#define proc_getmaxgroups   rb_f_notimplement

Definition at line 5973 of file process.c.

Referenced by InitVM_process().

◆ proc_getpgid

#define proc_getpgid   rb_f_notimplement

Definition at line 4493 of file process.c.

Referenced by InitVM_process().

◆ proc_getpgrp

#define proc_getpgrp   rb_f_notimplement

Definition at line 4440 of file process.c.

Referenced by InitVM_process(), and rb_f_sleep().

◆ proc_getpriority

#define proc_getpriority   rb_f_notimplement

Definition at line 4643 of file process.c.

Referenced by InitVM_process().

◆ proc_getrlimit

#define proc_getrlimit   rb_f_notimplement

Definition at line 4931 of file process.c.

Referenced by InitVM_process().

◆ proc_getsid

#define proc_getsid   rb_f_notimplement

Definition at line 4549 of file process.c.

Referenced by InitVM_process().

◆ proc_initgroups

#define proc_initgroups   rb_f_notimplement

Definition at line 5953 of file process.c.

Referenced by InitVM_process().

◆ proc_setegid_m

#define proc_setegid_m   rb_f_notimplement

Definition at line 6469 of file process.c.

Referenced by InitVM_process().

◆ proc_seteuid_m

#define proc_seteuid_m   rb_f_notimplement

Definition at line 6339 of file process.c.

Referenced by InitVM_process(), and proc_geteuid().

◆ proc_setgid

#define proc_setgid   rb_f_notimplement

Definition at line 5783 of file process.c.

Referenced by InitVM_process(), and proc_getgid().

◆ proc_setgroups

#define proc_setgroups   rb_f_notimplement

Definition at line 5922 of file process.c.

Referenced by InitVM_process().

◆ proc_setmaxgroups

#define proc_setmaxgroups   rb_f_notimplement

Definition at line 6005 of file process.c.

Referenced by InitVM_process().

◆ proc_setpgid

#define proc_setpgid   rb_f_notimplement

Definition at line 4518 of file process.c.

Referenced by InitVM_process().

◆ proc_setpgrp

#define proc_setpgrp   rb_f_notimplement

Definition at line 4468 of file process.c.

Referenced by InitVM_process().

◆ proc_setpriority

#define proc_setpriority   rb_f_notimplement

Definition at line 4674 of file process.c.

Referenced by InitVM_process().

◆ proc_setrlimit

#define proc_setrlimit   rb_f_notimplement

Definition at line 5007 of file process.c.

Referenced by InitVM_process().

◆ proc_setsid

#define proc_setsid   rb_f_notimplement

Definition at line 4607 of file process.c.

Referenced by InitVM_process().

◆ proc_setuid

#define proc_setuid   rb_f_notimplement

Definition at line 5377 of file process.c.

Referenced by InitVM_process(), and proc_getuid().

◆ PST2INT

#define PST2INT (   st)    NUM2INT(pst_to_i(st))

◆ rb_f_fork

#define rb_f_fork   rb_f_notimplement

Definition at line 3725 of file process.c.

Referenced by InitVM_process(), and rb_exec_async_signal_safe().

◆ rb_intern

#define rb_intern (   str)    rb_intern_const(str)

Referenced by Init_process().

◆ rb_proc_times

#define rb_proc_times   rb_f_notimplement

Definition at line 6936 of file process.c.

Referenced by InitVM_process(), and p_gid_switch().

◆ redirect_cloexec_dup

#define redirect_cloexec_dup (   oldfd)    rb_cloexec_dup(oldfd)

Definition at line 399 of file process.c.

Referenced by close_unless_reserved(), and save_redirect_fd().

◆ redirect_cloexec_dup2

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

Definition at line 400 of file process.c.

Referenced by close_unless_reserved().

◆ redirect_close

#define redirect_close (   fd)    close_unless_reserved(fd)

Definition at line 401 of file process.c.

Referenced by close_unless_reserved(), run_exec_close(), and run_exec_dup2().

◆ redirect_dup

#define redirect_dup (   oldfd)    dup(oldfd)

Definition at line 397 of file process.c.

Referenced by close_unless_reserved(), and run_exec_dup2().

◆ redirect_dup2

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

Definition at line 398 of file process.c.

Referenced by close_unless_reserved(), run_exec_dup2(), and run_exec_dup2_child().

◆ RUBY_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID

#define RUBY_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID   ID2SYM(id_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID)

◆ RUBY_GETTIMEOFDAY_BASED_CLOCK_REALTIME

#define RUBY_GETTIMEOFDAY_BASED_CLOCK_REALTIME   ID2SYM(id_GETTIMEOFDAY_BASED_CLOCK_REALTIME)

◆ 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 6948 of file process.c.

Referenced by timetick2integer().

◆ TIMETICK_INT_MAX

#define TIMETICK_INT_MAX   LONG_MAX

Definition at line 6947 of file process.c.

Referenced by timetick2integer().

◆ TIMETICK_INT_MIN

#define TIMETICK_INT_MIN   LONG_MIN

Definition at line 6946 of file process.c.

Referenced by timetick2integer().

◆ try_with_sh

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

Definition at line 1238 of file process.c.

Referenced by proc_exec_cmd().

◆ USE_SPAWNV

#define USE_SPAWNV   0

Definition at line 1390 of file process.c.

◆ WEXITSTATUS

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

Definition at line 116 of file process.c.

Referenced by pst_message(), pst_success_p(), and pst_wexitstatus().

◆ WIFEXITED

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

Definition at line 107 of file process.c.

Referenced by pst_message(), pst_success_p(), pst_wexitstatus(), and pst_wifexited().

◆ WIFSIGNALED

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

Definition at line 110 of file process.c.

Referenced by pst_message(), pst_wifsignaled(), and pst_wtermsig().

◆ WIFSTOPPED

#define WIFSTOPPED (   w)    (((w) & 0xff) == 0x7f)

Definition at line 113 of file process.c.

Referenced by pst_message(), pst_wifstopped(), and pst_wstopsig().

◆ WSTOPSIG

#define WSTOPSIG   WEXITSTATUS

Definition at line 122 of file process.c.

Referenced by pst_message(), and pst_wstopsig().

◆ WTERMSIG

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

Definition at line 119 of file process.c.

Referenced by pst_message(), and pst_wtermsig().

Typedef Documentation

◆ sig_t

typedef void(* sig_t) (int)

Definition at line 257 of file process.c.

◆ timetick_int_t

typedef long timetick_int_t

Definition at line 6945 of file process.c.

◆ unsigned_clock_t

typedef unsigned int unsigned_clock_t

Definition at line 250 of file process.c.

Function Documentation

◆ after_exec()

static void after_exec ( void  )
static

Definition at line 1201 of file process.c.

References after_exec_async_signal_safe(), and after_exec_non_async_signal_safe().

Referenced by rb_f_exec(), and rb_proc_exec().

◆ after_exec_async_signal_safe()

static void after_exec_async_signal_safe ( void  )
static

Definition at line 1189 of file process.c.

Referenced by after_exec().

◆ after_exec_non_async_signal_safe()

static void after_exec_non_async_signal_safe ( void  )
static

Definition at line 1194 of file process.c.

References rb_thread_reset_timer_thread(), and rb_thread_start_timer_thread().

Referenced by after_exec().

◆ before_exec()

static void before_exec ( void  )
static

Definition at line 1181 of file process.c.

References before_exec_async_signal_safe(), and before_exec_non_async_signal_safe().

Referenced by rb_f_exec(), and rb_proc_exec().

◆ before_exec_async_signal_safe()

static void before_exec_async_signal_safe ( void  )
static

Definition at line 1161 of file process.c.

Referenced by before_exec().

◆ before_exec_non_async_signal_safe()

static void before_exec_non_async_signal_safe ( void  )
static

Definition at line 1166 of file process.c.

References rb_thread_stop_timer_thread().

Referenced by before_exec().

◆ check_exec_env_i()

static int check_exec_env_i ( st_data_t  st_key,
st_data_t  st_val,
st_data_t  arg 
)
static

◆ check_exec_fds()

static VALUE check_exec_fds ( struct rb_execarg eargp)
static

◆ check_exec_fds_1()

static int check_exec_fds_1 ( struct rb_execarg eargp,
VALUE  h,
int  maxhint,
VALUE  ary 
)
static

◆ check_exec_options_i()

static int check_exec_options_i ( st_data_t  st_key,
st_data_t  st_val,
st_data_t  arg 
)
static

Definition at line 1813 of file process.c.

References key, PRIsVALUE, rb_eArgError, rb_execarg_addopt(), rb_raise(), ST_CONTINUE, SYMBOL_P, and val.

Referenced by rb_check_exec_options().

◆ check_exec_options_i_extract()

static int check_exec_options_i_extract ( st_data_t  st_key,
st_data_t  st_val,
st_data_t  arg 
)
static

Definition at line 1828 of file process.c.

References key, NIL_P, rb_execarg_addopt(), rb_hash_aset(), rb_hash_new(), ST_CONTINUE, and val.

Referenced by rb_execarg_extract_options().

◆ check_exec_redirect()

static void check_exec_redirect ( VALUE  key,
VALUE  val,
struct rb_execarg eargp 
)
static

◆ check_exec_redirect1()

static VALUE check_exec_redirect1 ( VALUE  ary,
VALUE  key,
VALUE  param 
)
static

◆ check_exec_redirect_fd()

static VALUE check_exec_redirect_fd ( VALUE  v,
int  iskey 
)
static

◆ check_gid_switch()

static void check_gid_switch ( void  )
static

◆ check_hash()

static VALUE check_hash ( VALUE  obj)
static

Definition at line 2017 of file process.c.

References Qnil, RB_BUILTIN_TYPE, rb_check_hash_type(), RB_SPECIAL_CONST_P, T_ARRAY, and T_STRING.

Referenced by rb_exec_getargs().

◆ check_uid_switch()

static void check_uid_switch ( void  )
static

◆ close_unless_reserved()

static int close_unless_reserved ( int  fd)
inlinestatic

◆ compare_posix_sh()

static int compare_posix_sh ( const void *  key,
const void *  el 
)
static

Definition at line 2067 of file process.c.

References key, string_part::len, and string_part::ptr.

Referenced by rb_exec_fillarg().

◆ CONSTFUNC()

CONSTFUNC ( static timetick_int_t   gcd_timetick_inttimetick_int_t, timetick_int_t)

◆ detach_process_pid()

static VALUE detach_process_pid ( VALUE  thread)
static

Definition at line 1079 of file process.c.

References id_pid, and rb_thread_local_aref().

Referenced by InitVM_process().

◆ detach_process_watcher()

static VALUE detach_process_watcher ( void *  arg)
static

Definition at line 1085 of file process.c.

References waitpid_arg::pid, rb_last_status_get(), and rb_waitpid().

Referenced by rb_detach_process().

◆ do_spawn_process()

static VALUE do_spawn_process ( VALUE  arg)
static

◆ do_waitpid()

static rb_pid_t do_waitpid ( rb_pid_t  pid,
int *  st,
int  flags 
)
static

Definition at line 869 of file process.c.

References NULL, and waitpid().

Referenced by rb_waitpid(), and rb_waitpid_blocking().

◆ do_waitpid_nonblocking()

static rb_pid_t do_waitpid_nonblocking ( rb_pid_t  pid,
int *  st,
int  flags 
)
static

◆ execarg_parent_end()

static VALUE execarg_parent_end ( VALUE  execarg_obj)
static

◆ exit_status_code()

static int exit_status_code ( VALUE  status)
static

Definition at line 3729 of file process.c.

References EXIT_FAILURE, EXIT_SUCCESS, NUM2INT, Qfalse, and Qtrue.

Referenced by rb_f_exit(), and rb_f_exit_bang().

◆ fd_clear_cloexec()

static int fd_clear_cloexec ( int  fd,
char *  errmsg,
size_t  errmsg_buflen 
)
static

Definition at line 2730 of file process.c.

References ERRMSG, F_GETFD, F_SETFD, fcntl(), and FD_CLOEXEC.

Referenced by run_exec_dup2().

◆ fd_get_cloexec()

static int fd_get_cloexec ( int  fd,
char *  errmsg,
size_t  errmsg_buflen 
)
static

Definition at line 2691 of file process.c.

References ERRMSG, F_GETFD, fcntl(), and FD_CLOEXEC.

Referenced by save_redirect_fd().

◆ fd_set_cloexec()

static int fd_set_cloexec ( int  fd,
char *  errmsg,
size_t  errmsg_buflen 
)
static

Definition at line 2707 of file process.c.

References ERRMSG, F_GETFD, F_SETFD, fcntl(), and FD_CLOEXEC.

Referenced by run_exec_dup2().

◆ fill_envp_buf_i()

static int fill_envp_buf_i ( st_data_t  st_key,
st_data_t  st_val,
st_data_t  arg 
)
static

◆ gcd_timetick_int()

static timetick_int_t gcd_timetick_int ( timetick_int_t  a,
timetick_int_t  b 
)
static

Definition at line 6953 of file process.c.

Referenced by reduce_fraction().

◆ get_pid()

static VALUE get_pid ( void  )
static

Definition at line 417 of file process.c.

References PIDT2NUM.

Referenced by InitVM_process().

◆ get_ppid()

static VALUE get_ppid ( void  )
static

Definition at line 440 of file process.c.

References PIDT2NUM.

Referenced by InitVM_process().

◆ hide_obj()

static VALUE hide_obj ( VALUE  obj)
static

◆ Init_process()

void Init_process ( void  )

◆ InitVM_process()

void InitVM_process ( void  )

Definition at line 7578 of file process.c.

References CLASS_OF, CLOCK_MONOTONIC, CLOCK_REALTIME, detach_process_pid(), get_pid(), get_ppid(), getegid(), geteuid(), inf(), INT2FIX, NULL, p_gid_change_privilege(), p_gid_exchange(), p_gid_exchangeable(), p_gid_from_name, p_gid_grant_privilege(), p_gid_have_saved_id(), p_gid_switch(), 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_change_privilege(), p_uid_exchange(), p_uid_exchangeable(), p_uid_from_name, p_uid_grant_privilege(), p_uid_have_saved_id(), p_uid_switch(), proc_daemon, proc_detach(), proc_getegid(), proc_geteuid(), proc_getgid(), proc_getgroups, proc_getmaxgroups, proc_getpgid, proc_getpgrp, proc_getpriority, proc_getrlimit, proc_getsid, proc_getuid(), 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, proc_wait(), proc_wait2(), proc_waitall(), pst_bitand(), pst_equal(), pst_inspect(), pst_pid(), pst_rshift(), pst_success_p(), pst_to_i(), pst_to_s(), pst_wcoredump(), pst_wexitstatus(), pst_wifexited(), pst_wifsignaled(), pst_wifstopped(), pst_wstopsig(), pst_wtermsig(), rb_clock_getres(), rb_clock_gettime(), rb_cObject, rb_cProcessStatus, rb_cStruct, rb_cThread, rb_cWaiter, rb_define_alias(), 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(), rb_define_virtual_variable(), rb_f_abort(), rb_f_exec(), rb_f_exit(), rb_f_exit_bang(), rb_f_fork, rb_f_kill(), rb_f_sleep(), rb_f_spawn(), rb_f_system(), rb_last_status_get(), rb_proc_times, rb_singleton_class(), rb_struct_define_under(), rb_undef_alloc_func(), rb_undef_method(), RUBY_GETTIMEOFDAY_BASED_CLOCK_REALTIME, and WNOHANG.

◆ intcmp()

static int intcmp ( const void *  a,
const void *  b 
)
static

Definition at line 2664 of file process.c.

Referenced by run_exec_dup2().

◆ intrcmp()

static int intrcmp ( const void *  a,
const void *  b 
)
static

Definition at line 2670 of file process.c.

Referenced by run_exec_dup2().

◆ make_clock_result()

static VALUE make_clock_result ( struct timetick ttp,
timetick_int_t numerators,
int  num_numerators,
timetick_int_t denominators,
int  num_denominators,
VALUE  unit 
)
static

◆ mark_exec_arg()

static void mark_exec_arg ( void *  ptr)
static

◆ memsize_exec_arg()

static size_t memsize_exec_arg ( const void *  ptr)
static

Definition at line 1358 of file process.c.

◆ open_func()

static void* open_func ( void *  ptr)
static

◆ p_gid_change_privilege()

static VALUE p_gid_change_privilege ( VALUE  obj,
VALUE  id 
)
static

◆ p_gid_exchange()

static VALUE p_gid_exchange ( VALUE  obj)
static

◆ p_gid_exchangeable()

static VALUE p_gid_exchangeable ( void  )
static

Definition at line 6606 of file process.c.

References Qfalse, and Qtrue.

Referenced by InitVM_process().

◆ p_gid_grant_privilege()

static VALUE p_gid_grant_privilege ( VALUE  obj,
VALUE  id 
)
static

Definition at line 6527 of file process.c.

References id, OBJ2GID, and rb_setegid_core().

Referenced by InitVM_process().

◆ p_gid_have_saved_id()

static VALUE p_gid_have_saved_id ( void  )
static

◆ p_gid_sw_ensure()

static VALUE p_gid_sw_ensure ( VALUE  obj)
static

Definition at line 6853 of file process.c.

References p_gid_exchange().

Referenced by p_gid_have_saved_id(), and p_gid_switch().

◆ p_gid_switch()

static VALUE p_gid_switch ( VALUE  obj)
static

◆ p_uid_change_privilege()

static VALUE p_uid_change_privilege ( VALUE  obj,
VALUE  id 
)
static

◆ p_uid_exchange()

static VALUE p_uid_exchange ( VALUE  obj)
static

◆ p_uid_exchangeable()

static VALUE p_uid_exchangeable ( void  )
static

Definition at line 6544 of file process.c.

References Qfalse, and Qtrue.

Referenced by InitVM_process().

◆ p_uid_grant_privilege()

static VALUE p_uid_grant_privilege ( VALUE  obj,
VALUE  id 
)
static

Definition at line 6397 of file process.c.

References id, OBJ2UID, and rb_seteuid_core().

Referenced by InitVM_process().

◆ p_uid_have_saved_id()

static VALUE p_uid_have_saved_id ( void  )
static

◆ p_uid_sw_ensure()

static VALUE p_uid_sw_ensure ( VALUE  obj)
static

Definition at line 6740 of file process.c.

References p_uid_exchange().

Referenced by p_uid_have_saved_id(), and p_uid_switch().

◆ p_uid_switch()

static VALUE p_uid_switch ( VALUE  obj)
static

◆ proc_detach()

static VALUE proc_detach ( VALUE  obj,
VALUE  pid 
)
static

Definition at line 1154 of file process.c.

References NUM2PIDT, and rb_detach_process().

Referenced by InitVM_process().

◆ proc_exec_cmd()

static int proc_exec_cmd ( const char *  prog,
VALUE  argv_str,
VALUE  envp_str 
)
static

◆ proc_exec_sh()

static int proc_exec_sh ( const char *  str,
VALUE  envp_str 
)
static

◆ proc_getegid()

static VALUE proc_getegid ( VALUE  obj)
static

◆ proc_geteuid()

static VALUE proc_geteuid ( VALUE  obj)
static

◆ proc_getgid()

static VALUE proc_getgid ( VALUE  obj)
static

◆ proc_getuid()

static VALUE proc_getuid ( VALUE  obj)
static

◆ proc_wait()

static VALUE proc_wait ( int  argc,
VALUE argv 
)
static

◆ proc_wait2()

static VALUE proc_wait2 ( int  argc,
VALUE argv 
)
static

Definition at line 1025 of file process.c.

References NIL_P, waitpid_arg::pid, proc_wait(), Qnil, rb_assoc_new(), and rb_last_status_get().

Referenced by InitVM_process().

◆ proc_waitall()

static VALUE proc_waitall ( void  )
static

◆ pst_bitand()

static VALUE pst_bitand ( VALUE  st1,
VALUE  st2 
)
static

Definition at line 660 of file process.c.

References INT2NUM, NUM2INT, and PST2INT.

Referenced by InitVM_process().

◆ pst_equal()

static VALUE pst_equal ( VALUE  st1,
VALUE  st2 
)
static

Definition at line 640 of file process.c.

References pst_to_i(), Qtrue, and rb_equal().

Referenced by InitVM_process().

◆ pst_inspect()

static VALUE pst_inspect ( VALUE  st)
static

Definition at line 611 of file process.c.

References CLASS_OF, NIL_P, NUM2PIDT, PST2INT, pst_message(), pst_pid(), rb_class2name(), rb_sprintf(), and rb_str_cat2().

Referenced by InitVM_process().

◆ pst_message()

static void pst_message ( VALUE  str,
rb_pid_t  pid,
int  status 
)
static

◆ pst_pid()

static VALUE pst_pid ( VALUE  st)
static

Definition at line 532 of file process.c.

References id_pid, and rb_attr_get().

Referenced by InitVM_process(), pst_inspect(), and pst_to_s().

◆ pst_rshift()

static VALUE pst_rshift ( VALUE  st1,
VALUE  st2 
)
static

Definition at line 681 of file process.c.

References INT2NUM, NUM2INT, and PST2INT.

Referenced by InitVM_process().

◆ pst_success_p()

static VALUE pst_success_p ( VALUE  st)
static

Definition at line 829 of file process.c.

References EXIT_SUCCESS, PST2INT, Qfalse, Qnil, Qtrue, WEXITSTATUS, and WIFEXITED.

Referenced by InitVM_process().

◆ pst_to_i()

static VALUE pst_to_i ( VALUE  st)
static

Definition at line 513 of file process.c.

References id_status, and rb_ivar_get().

Referenced by InitVM_process(), and pst_equal().

◆ pst_to_s()

static VALUE pst_to_s ( VALUE  st)
static

Definition at line 584 of file process.c.

References NUM2PIDT, PST2INT, pst_message(), pst_pid(), and rb_str_buf_new().

Referenced by InitVM_process().

◆ pst_wcoredump()

static VALUE pst_wcoredump ( VALUE  st)
static

Definition at line 848 of file process.c.

References PST2INT, Qfalse, and Qtrue.

Referenced by InitVM_process().

◆ pst_wexitstatus()

static VALUE pst_wexitstatus ( VALUE  st)
static

Definition at line 810 of file process.c.

References INT2NUM, PST2INT, Qnil, WEXITSTATUS, and WIFEXITED.

Referenced by InitVM_process().

◆ pst_wifexited()

static VALUE pst_wifexited ( VALUE  st)
static

Definition at line 779 of file process.c.

References PST2INT, Qfalse, Qtrue, and WIFEXITED.

Referenced by InitVM_process().

◆ pst_wifsignaled()

static VALUE pst_wifsignaled ( VALUE  st)
static

Definition at line 738 of file process.c.

References PST2INT, Qfalse, Qtrue, and WIFSIGNALED.

Referenced by InitVM_process().

◆ pst_wifstopped()

static VALUE pst_wifstopped ( VALUE  st)
static

Definition at line 699 of file process.c.

References PST2INT, Qfalse, Qtrue, and WIFSTOPPED.

Referenced by InitVM_process().

◆ pst_wstopsig()

static VALUE pst_wstopsig ( VALUE  st)
static

Definition at line 719 of file process.c.

References INT2NUM, PST2INT, Qnil, WIFSTOPPED, and WSTOPSIG.

Referenced by InitVM_process().

◆ pst_wtermsig()

static VALUE pst_wtermsig ( VALUE  st)
static

Definition at line 759 of file process.c.

References INT2NUM, PST2INT, Qnil, WIFSIGNALED, and WTERMSIG.

Referenced by InitVM_process().

◆ rb_check_argv()

static VALUE rb_check_argv ( int  argc,
VALUE argv 
)
static

◆ rb_check_exec_env()

static VALUE rb_check_exec_env ( VALUE  hash,
VALUE path 
)
static

◆ rb_check_exec_options()

static void rb_check_exec_options ( VALUE  opthash,
VALUE  execarg_obj 
)
static

Definition at line 1920 of file process.c.

References check_exec_options_i(), rb_hash_tbl_raw(), RHASH_EMPTY_P, st_data_t, and st_foreach.

Referenced by rb_exec_fillarg().

◆ rb_clock_getres()

VALUE rb_clock_getres ( int  argc,
VALUE argv 
)

◆ rb_clock_gettime()

VALUE rb_clock_gettime ( int  argc,
VALUE argv 
)

◆ rb_detach_process()

VALUE rb_detach_process ( rb_pid_t  pid)

◆ rb_exec_async_signal_safe()

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

◆ rb_exec_fail()

static void rb_exec_fail ( struct rb_execarg eargp,
int  err,
const char *  errmsg 
)
static

Definition at line 2503 of file process.c.

References rb_execarg::chdir_dir, err, rb_execarg_get(), RB_GC_GUARD, rb_sys_fail(), and rb_sys_fail_str().

Referenced by rb_f_exec(), and rb_f_spawn().

◆ rb_exec_fillarg()

static void rb_exec_fillarg ( VALUE  prog,
int  argc,
VALUE argv,
VALUE  env,
VALUE  opthash,
VALUE  execarg_obj 
)
static

◆ rb_exec_getargs()

static VALUE rb_exec_getargs ( int *  argc_p,
VALUE **  argv_p,
int  accept_shell,
VALUE env_ret,
VALUE opthash_ret 
)
static

Definition at line 2029 of file process.c.

References check_hash(), hash(), NIL_P, and rb_check_argv().

Referenced by rb_execarg_init().

◆ rb_execarg_addopt()

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

◆ rb_execarg_commandline()

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

◆ rb_execarg_extract_options()

VALUE rb_execarg_extract_options ( VALUE  execarg_obj,
VALUE  opthash 
)

Definition at line 1928 of file process.c.

References check_exec_options_i_extract(), Qnil, rb_hash_tbl_raw(), RHASH_EMPTY_P, st_data_t, and st_foreach.

Referenced by rb_io_s_popen().

◆ rb_execarg_get()

struct rb_execarg* rb_execarg_get ( VALUE  execarg_obj)

◆ rb_execarg_init()

VALUE rb_execarg_init ( int  argc,
const VALUE orig_argv,
int  accept_shell,
VALUE  execarg_obj 
)

◆ rb_execarg_new()

VALUE rb_execarg_new ( int  argc,
const VALUE argv,
int  accept_shell 
)

◆ rb_execarg_parent_end()

void rb_execarg_parent_end ( VALUE  execarg_obj)

Definition at line 2496 of file process.c.

References execarg_parent_end(), and RB_GC_GUARD.

Referenced by establishShell(), pipe_open(), and rb_execarg_parent_start().

◆ rb_execarg_parent_start()

void rb_execarg_parent_start ( VALUE  execarg_obj)

◆ rb_execarg_parent_start1()

static VALUE rb_execarg_parent_start1 ( VALUE  execarg_obj)
static

◆ rb_execarg_run_options()

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

◆ rb_execarg_setenv()

void rb_execarg_setenv ( VALUE  execarg_obj,
VALUE  env 
)

◆ rb_execarg_spawn()

static rb_pid_t rb_execarg_spawn ( VALUE  execarg_obj,
char *  errmsg,
size_t  errmsg_buflen 
)
static

◆ rb_exit()

void rb_exit ( int  status)

◆ rb_f_abort()

VALUE rb_f_abort ( int  argc,
const VALUE argv 
)

◆ rb_f_exec()

VALUE rb_f_exec ( int  argc,
const VALUE argv 
)

◆ rb_f_exit()

VALUE rb_f_exit ( int  argc,
const VALUE argv 
)

Definition at line 3834 of file process.c.

References exit_status_code(), EXIT_SUCCESS, rb_check_arity, rb_exit(), and UNREACHABLE.

Referenced by InitVM_process().

◆ rb_f_exit_bang()

static VALUE rb_f_exit_bang ( int  argc,
VALUE argv,
VALUE  obj 
)
static

Definition at line 3763 of file process.c.

References EXIT_FAILURE, exit_status_code(), rb_check_arity, and UNREACHABLE.

Referenced by InitVM_process().

◆ rb_f_sleep()

static VALUE rb_f_sleep ( int  argc,
VALUE argv 
)
static

◆ rb_f_spawn()

static VALUE rb_f_spawn ( int  argc,
VALUE argv 
)
static

◆ rb_f_system()

static VALUE rb_f_system ( int  argc,
VALUE argv 
)
static

◆ rb_last_status_clear()

void rb_last_status_clear ( void  )

Definition at line 494 of file process.c.

References GET_THREAD, and Qnil.

Referenced by fptr_waitpid(), proc_wait(), proc_waitall(), rb_f_backquote(), and rb_f_system().

◆ rb_last_status_get()

VALUE rb_last_status_get ( void  )

◆ rb_last_status_set()

void rb_last_status_set ( int  status,
rb_pid_t  pid 
)

◆ rb_proc_exec()

int rb_proc_exec ( const char *  str)

Definition at line 1322 of file process.c.

References after_exec(), before_exec(), preserving_errno, proc_exec_sh(), and Qfalse.

◆ rb_setegid_core()

static rb_gid_t rb_setegid_core ( rb_gid_t  egid)
static

◆ rb_seteuid_core()

static rb_uid_t rb_seteuid_core ( rb_uid_t  euid)
static

◆ rb_spawn()

rb_pid_t rb_spawn ( int  argc,
const VALUE argv 
)

Definition at line 4006 of file process.c.

References NULL, and rb_spawn_internal().

◆ rb_spawn_err()

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

Definition at line 4000 of file process.c.

References rb_spawn_internal().

◆ rb_spawn_internal()

static rb_pid_t rb_spawn_internal ( int  argc,
const VALUE argv,
char *  errmsg,
size_t  errmsg_buflen 
)
static

Definition at line 3991 of file process.c.

References rb_execarg_new(), rb_execarg_spawn(), and TRUE.

Referenced by rb_f_system(), rb_spawn(), and rb_spawn_err().

◆ rb_spawn_process()

static rb_pid_t rb_spawn_process ( struct rb_execarg eargp,
char *  errmsg,
size_t  errmsg_buflen 
)
static

◆ rb_syswait()

void rb_syswait ( rb_pid_t  pid)

Definition at line 3885 of file process.c.

References rb_waitpid().

Referenced by rb_exec_async_signal_safe().

◆ rb_waitpid()

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

◆ rb_waitpid_blocking()

static void* rb_waitpid_blocking ( void *  data)
static

Definition at line 881 of file process.c.

References do_waitpid(), waitpid_arg::flags, waitpid_arg::pid, result, and waitpid_arg::st.

Referenced by do_waitpid_nonblocking().

◆ reduce_factors()

static void reduce_factors ( timetick_int_t numerators,
int  num_numerators,
timetick_int_t denominators,
int  num_denominators 
)
static

Definition at line 6983 of file process.c.

References reduce_fraction().

Referenced by timetick2dblnum(), timetick2dblnum_reciprocal(), and timetick2integer().

◆ reduce_fraction()

static void reduce_fraction ( timetick_int_t np,
timetick_int_t dp 
)
static

Definition at line 6973 of file process.c.

References gcd_timetick_int().

Referenced by reduce_factors().

◆ run_exec_close()

static int run_exec_close ( VALUE  ary,
char *  errmsg,
size_t  errmsg_buflen 
)
static

Definition at line 2876 of file process.c.

References ERRMSG, FIX2INT, RARRAY_AREF, RARRAY_LEN, and redirect_close.

Referenced by rb_execarg_run_options().

◆ run_exec_dup2()

static int run_exec_dup2 ( VALUE  ary,
VALUE  tmpbuf,
struct rb_execarg sargp,
char *  errmsg,
size_t  errmsg_buflen 
)
static

◆ run_exec_dup2_child()

static int run_exec_dup2_child ( VALUE  ary,
struct rb_execarg sargp,
char *  errmsg,
size_t  errmsg_buflen 
)
static

◆ run_exec_dup2_tmpbuf_size()

static long run_exec_dup2_tmpbuf_size ( long  n)
static

Definition at line 2684 of file process.c.

Referenced by fill_envp_buf_i(), rb_execarg_parent_start1(), and rb_execarg_run_options().

◆ save_env()

static void save_env ( struct rb_execarg sargp)
static

◆ save_env_i()

static VALUE save_env_i ( RB_BLOCK_CALL_FUNC_ARGLIST(i, ary)  )
static

Definition at line 2989 of file process.c.

References argv, hide_obj(), Qnil, rb_ary_dup(), and rb_ary_push().

Referenced by save_env().

◆ save_redirect_fd()

static int save_redirect_fd ( int  fd,
struct rb_execarg sargp,
char *  errmsg,
size_t  errmsg_buflen 
)
static

◆ security()

static void security ( const char *  str)
static

Definition at line 1213 of file process.c.

References argv, rb_env_path_tainted(), rb_eSecurityError, rb_raise(), and rb_safe_level().

Referenced by rb_check_argv().

◆ timetick2dblnum()

static VALUE timetick2dblnum ( struct timetick ttp,
timetick_int_t numerators,
int  num_numerators,
timetick_int_t denominators,
int  num_denominators 
)
static

Definition at line 7004 of file process.c.

References timetick::count, DBL2NUM, timetick::giga_count, and reduce_factors().

Referenced by make_clock_result().

◆ timetick2dblnum_reciprocal()

static VALUE timetick2dblnum_reciprocal ( struct timetick ttp,
timetick_int_t numerators,
int  num_numerators,
timetick_int_t denominators,
int  num_denominators 
)
static

Definition at line 7025 of file process.c.

References timetick::count, DBL2NUM, timetick::giga_count, and reduce_factors().

Referenced by rb_clock_getres().

◆ timetick2integer()

static VALUE timetick2integer ( struct timetick ttp,
timetick_int_t numerators,
int  num_numerators,
timetick_int_t denominators,
int  num_denominators 
)
static

Variable Documentation

◆ exec_arg_data_type

const rb_data_type_t exec_arg_data_type
static
Initial value:
= {
"exec_arg",
}
#define RUBY_TYPED_FREE_IMMEDIATELY
Definition: ruby.h:1145
static void mark_exec_arg(void *ptr)
Definition: process.c:1332
static size_t memsize_exec_arg(const void *ptr)
Definition: process.c:1358
#define RUBY_TYPED_DEFAULT_FREE
Definition: ruby.h:1141

Definition at line 1363 of file process.c.

◆ id_chdir

ID id_chdir
static

Definition at line 268 of file process.c.

Referenced by Init_process(), and rb_execarg_addopt().

◆ id_child

ID id_child
static

Definition at line 261 of file process.c.

Referenced by check_exec_redirect(), and Init_process().

◆ id_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID

ID id_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID
static

Definition at line 279 of file process.c.

Referenced by Init_process().

◆ id_close

ID id_close
static

Definition at line 261 of file process.c.

Referenced by check_exec_redirect(), and Init_process().

◆ id_close_others

ID id_close_others
static

Definition at line 268 of file process.c.

Referenced by Init_process(), and rb_execarg_addopt().

◆ id_ENV

ID id_ENV
static

Definition at line 268 of file process.c.

Referenced by Init_process(), rb_execarg_parent_start1(), and save_env().

◆ id_err

ID id_err
static

◆ id_float_microsecond

ID id_float_microsecond
static

Definition at line 270 of file process.c.

Referenced by Init_process(), and make_clock_result().

◆ id_float_millisecond

ID id_float_millisecond
static

Definition at line 270 of file process.c.

Referenced by Init_process(), and make_clock_result().

◆ id_float_second

ID id_float_second
static

Definition at line 270 of file process.c.

Referenced by Init_process(), and make_clock_result().

◆ id_GETTIMEOFDAY_BASED_CLOCK_REALTIME

ID id_GETTIMEOFDAY_BASED_CLOCK_REALTIME
static

Definition at line 271 of file process.c.

Referenced by Init_process().

◆ id_gid

ID id_gid
static

Definition at line 260 of file process.c.

Referenced by Init_process(), and rb_execarg_addopt().

◆ id_hertz

ID id_hertz
static

Definition at line 283 of file process.c.

Referenced by Init_process(), and rb_clock_getres().

◆ id_in

ID id_in
static

◆ id_microsecond

ID id_microsecond
static

Definition at line 269 of file process.c.

Referenced by Init_process(), and make_clock_result().

◆ id_millisecond

ID id_millisecond
static

Definition at line 269 of file process.c.

Referenced by Init_process(), and make_clock_result().

◆ id_nanosecond

ID id_nanosecond
static

Definition at line 269 of file process.c.

Referenced by Init_process(), and make_clock_result().

◆ id_out

ID id_out
static

◆ id_pid

ID id_pid
static

◆ id_second

ID id_second
static

Definition at line 269 of file process.c.

Referenced by Init_process(), and make_clock_result().

◆ id_TIME_BASED_CLOCK_REALTIME

ID id_TIME_BASED_CLOCK_REALTIME
static

Definition at line 271 of file process.c.

Referenced by Init_process().

◆ id_uid

ID id_uid
static

Definition at line 260 of file process.c.

Referenced by Init_process(), and rb_execarg_addopt().

◆ id_umask

ID id_umask
static

Definition at line 268 of file process.c.

Referenced by Init_process(), and rb_execarg_addopt().

◆ id_unsetenv_others

ID id_unsetenv_others
static

Definition at line 268 of file process.c.

Referenced by Init_process(), and rb_execarg_addopt().

◆ rb_cProcessStatus

VALUE rb_cProcessStatus
static

Definition at line 476 of file process.c.

Referenced by InitVM_process(), and rb_last_status_set().

◆ rb_cWaiter

VALUE rb_cWaiter
static

Definition at line 1076 of file process.c.

Referenced by InitVM_process(), and rb_detach_process().

◆ rb_mProcess

VALUE rb_mProcess

Definition at line 7566 of file process.c.

◆ rb_mProcGID

VALUE rb_mProcGID

Definition at line 7568 of file process.c.

◆ rb_mProcID_Syscall

VALUE rb_mProcID_Syscall

Definition at line 7569 of file process.c.

◆ rb_mProcUID

VALUE rb_mProcUID

Definition at line 7567 of file process.c.

◆ ruby_static_id_status

ID ruby_static_id_status

Definition at line 27 of file eval.c.

◆ SAVED_GROUP_ID

rb_gid_t SAVED_GROUP_ID = -1
static

Definition at line 6095 of file process.c.

◆ SAVED_USER_ID

rb_uid_t SAVED_USER_ID = -1
static

Definition at line 5391 of file process.c.

◆ under_gid_switch

int under_gid_switch = 0
static

Definition at line 5019 of file process.c.

◆ under_uid_switch

int under_uid_switch = 0
static

Definition at line 5010 of file process.c.