1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* internal.h (rb_execarg): add env_modification field.

* process.c (EXEC_OPTION_ENV): removed.
  (mark_exec_arg): mark env_modification field.
  (rb_exec_fillarg): update the new field, instead of options array.
  (rb_execarg_fixup): use the new field.
  (save_env): ditto.
  (rb_execarg_run_options): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2012-06-23 08:18:34 +00:00
parent f732c5046e
commit 26ecb6cbc4
3 changed files with 20 additions and 8 deletions

View file

@ -1,3 +1,14 @@
Sat Jun 23 17:04:08 2012 Tanaka Akira <akr@fsij.org>
* internal.h (rb_execarg): add env_modification field.
* process.c (EXEC_OPTION_ENV): removed.
(mark_exec_arg): mark env_modification field.
(rb_exec_fillarg): update the new field, instead of options array.
(rb_execarg_fixup): use the new field.
(save_env): ditto.
(rb_execarg_run_options): ditto.
Sat Jun 23 16:27:01 2012 Tanaka Akira <akr@fsij.org>
* internal.h (rb_execarg): add rlimit_limits field.

View file

@ -187,6 +187,7 @@ struct rb_execarg {
VALUE rlimit_limits; /* Qfalse or [[rtype, softlim, hardlim], ...] */
mode_t umask_mask;
int close_others_maxhint;
VALUE env_modification; /* Qfalse or [[k1,v1], ...] */
VALUE chdir_dir;
};

View file

@ -1254,7 +1254,6 @@ rb_proc_exec(const char *str)
}
enum {
EXEC_OPTION_ENV,
EXEC_OPTION_DUP2,
EXEC_OPTION_CLOSE,
EXEC_OPTION_OPEN,
@ -1280,6 +1279,7 @@ mark_exec_arg(void *ptr)
rb_gc_mark(eargp->envp_buf);
rb_gc_mark(eargp->dup2_tmpbuf);
rb_gc_mark(eargp->rlimit_limits);
rb_gc_mark(eargp->env_modification);
rb_gc_mark(eargp->chdir_dir);
}
@ -1896,7 +1896,7 @@ rb_exec_fillarg(VALUE prog, int argc, VALUE *argv, VALUE env, VALUE opthash, VAL
}
if (!NIL_P(env)) {
env = rb_check_exec_env(env);
rb_ary_store(options, EXEC_OPTION_ENV, env);
eargp->env_modification = env;
}
eargp->use_shell = argc == 0;
@ -2128,8 +2128,8 @@ rb_execarg_fixup(VALUE execarg_obj)
}
unsetenv_others = eargp->unsetenv_others_given && eargp->unsetenv_others_do;
envopts = rb_ary_entry(eargp->options, EXEC_OPTION_ENV);
if (unsetenv_others || !NIL_P(envopts)) {
envopts = eargp->env_modification;
if (unsetenv_others || envopts != Qfalse) {
VALUE envtbl, envp_str, envp_buf;
char *p, *ep;
if (unsetenv_others) {
@ -2705,13 +2705,13 @@ save_env(struct rb_execarg *sargp)
if (!sargp)
return;
soptions = sargp->options;
if (NIL_P(rb_ary_entry(soptions, EXEC_OPTION_ENV))) {
if (sargp->env_modification == Qfalse) {
VALUE env = rb_const_get(rb_cObject, rb_intern("ENV"));
if (RTEST(env)) {
VALUE ary = hide_obj(rb_ary_new());
rb_block_call(env, rb_intern("each"), 0, 0, save_env_i,
(VALUE)ary);
rb_ary_store(soptions, EXEC_OPTION_ENV, ary);
sargp->env_modification = ary;
}
rb_ary_store(soptions, EXEC_OPTION_UNSETENV_OTHERS, Qtrue);
}
@ -2757,8 +2757,8 @@ rb_execarg_run_options(const struct rb_execarg *eargp, struct rb_execarg *sargp,
rb_env_clear();
}
obj = rb_ary_entry(options, EXEC_OPTION_ENV);
if (!NIL_P(obj)) {
obj = eargp->env_modification;
if (obj != Qfalse) {
long i;
save_env(sargp);
for (i = 0; i < RARRAY_LEN(obj); i++) {