From 414c32242778be8853a2c31bdae59467a75fae50 Mon Sep 17 00:00:00 2001 From: akr Date: Thu, 24 Apr 2008 14:46:39 +0000 Subject: * include/ruby/intern.h (rb_env_clear): declared. (rb_io_mode_modenum): declared. (rb_close_before_exec): declared. (struct rb_exec_arg): add options and redirect_fds field. (rb_check_argv): removed. (rb_exec_initarg): declared. (rb_exec_getargs): declared. (rb_exec_initarg2): declared. (rb_fork): add third argument: fds. * io.c (max_file_descriptor): new static variable to record maximum file descriptor ruby used. (UPDATE_MAXFD): new macro. (UPDATE_MAXFD_PIPE): new macro. (rb_io_mode_modenum): externed. (rb_sysopen): update max_file_descriptor. (rb_close_before_exec): new function. (popen_exec): redirection removed because it is done by extended spawn mechanism. (pipe_open): generate a hash for spawn options to specify redirections. (pipe_open_v): use rb_exec_getargs. (pipe_open_s): use rb_exec_getargs. (rb_io_initialize): update max_file_descriptor.. * process.c (hide_obj): new function. (check_exec_redirect_fd): new function. (check_exec_redirect): new function. (check_exec_options_i): new function. (check_exec_fds): new function. (rb_check_exec_options): new function. (check_exec_env_i): new function. (rb_check_exec_env): new function. (rb_exec_getargs): new function. (rb_exec_initarg2): new function. (rb_exec_initarg): new function. (rb_f_exec): use rb_exec_initarg. (intcmp): new function. (run_exec_dup2): new function. (run_exec_close): new function. (run_exec_open): new function. (run_exec_pgroup): new function. (run_exec_rlimit): new function. (run_exec_options): new function. (rb_exec): call run_exec_options. (move_fds_to_avoid_crash): new function. (pipe_nocrash): new function. (rb_fork): use pipe_nocrash to avoid file descriptor conflicts. (rb_spawn): use rb_exec_initarg. (rlimit_resource_name2int): extracted from rlimit_resource_type. (rlimit_type_by_hname): new function. (rlimit_type_by_lname): new function. (rlimit_resource_type): use rlimit_type_by_hname. (proc_daemon): add fds argument for rb_fork. * hash.c (rb_env_clear): renamed from env_clear and externed. [ruby-dev:34086] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- include/ruby/intern.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'include/ruby') diff --git a/include/ruby/intern.h b/include/ruby/intern.h index 7e20439da..71538e6af 100644 --- a/include/ruby/intern.h +++ b/include/ruby/intern.h @@ -353,6 +353,7 @@ VALUE rb_hash_delete(VALUE,VALUE); struct st_table *rb_hash_tbl(VALUE); int rb_path_check(const char*); int rb_env_path_tainted(void); +VALUE rb_env_clear(void); /* io.c */ #define rb_defout rb_stdout RUBY_EXTERN VALUE rb_fs; @@ -377,6 +378,8 @@ VALUE rb_file_open(const char*, const char*); VALUE rb_gets(void); void rb_write_error(const char*); void rb_write_error2(const char*, long); +int rb_io_mode_modenum(const char *mode); +void rb_close_before_exec(int lowfd, int maxhint, VALUE noclose_fds); /* marshal.c */ VALUE rb_marshal_dump(VALUE, VALUE); VALUE rb_marshal_load(VALUE); @@ -444,12 +447,16 @@ struct rb_exec_arg { int argc; VALUE *argv; const char *prog; + VALUE options; + VALUE redirect_fds; }; int rb_proc_exec_n(int, VALUE*, const char*); int rb_proc_exec(const char*); -VALUE rb_check_argv(int, VALUE*); +VALUE rb_exec_initarg(int argc, VALUE *argv, int accept_shell, struct rb_exec_arg *e); +VALUE rb_exec_getargs(int *argc_p, VALUE **argv_p, int accept_shell, VALUE *env_ret, VALUE *opthash_ret); +void rb_exec_initarg2(VALUE prog, int argc, VALUE *argv, VALUE env, VALUE opthash, struct rb_exec_arg *e); int rb_exec(const struct rb_exec_arg*); -rb_pid_t rb_fork(int*, int (*)(void*), void*); +rb_pid_t rb_fork(int*, int (*)(void*), void*, VALUE); VALUE rb_f_exec(int,VALUE*); rb_pid_t rb_waitpid(rb_pid_t pid, int *status, int flags); void rb_syswait(rb_pid_t pid); -- cgit