mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* internal.h (rb_execarg): add chdir_given and chdir_dir fields.
* process.c (EXEC_OPTION_CHDIR): removed. (mark_exec_arg): mark chdir_dir field. (rb_execarg_addopt): update the new fields, instead of options array. (rb_execarg_run_options): use the new fields. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f527ad625d
commit
b25b9569e5
3 changed files with 19 additions and 9 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
Sat Jun 23 14:29:25 2012 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* internal.h (rb_execarg): add chdir_given and chdir_dir fields.
|
||||||
|
|
||||||
|
* process.c (EXEC_OPTION_CHDIR): removed.
|
||||||
|
(mark_exec_arg): mark chdir_dir field.
|
||||||
|
(rb_execarg_addopt): update the new fields, instead of options array.
|
||||||
|
(rb_execarg_run_options): use the new fields.
|
||||||
|
|
||||||
Sat Jun 23 13:20:47 2012 Tanaka Akira <akr@fsij.org>
|
Sat Jun 23 13:20:47 2012 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* internal.h (rb_execarg): add close_others_given, close_others_do and
|
* internal.h (rb_execarg): add close_others_given, close_others_do and
|
||||||
|
|
|
@ -182,9 +182,11 @@ struct rb_execarg {
|
||||||
unsigned unsetenv_others_do : 1;
|
unsigned unsetenv_others_do : 1;
|
||||||
unsigned close_others_given : 1;
|
unsigned close_others_given : 1;
|
||||||
unsigned close_others_do : 1;
|
unsigned close_others_do : 1;
|
||||||
|
unsigned chdir_given : 1;
|
||||||
pid_t pgroup_pgid; /* asis(-1), new pgroup(0), specified pgroup (0<V). */
|
pid_t pgroup_pgid; /* asis(-1), new pgroup(0), specified pgroup (0<V). */
|
||||||
mode_t umask_mask;
|
mode_t umask_mask;
|
||||||
int close_others_maxhint;
|
int close_others_maxhint;
|
||||||
|
VALUE chdir_dir;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* argv_str contains extra two elements.
|
/* argv_str contains extra two elements.
|
||||||
|
|
17
process.c
17
process.c
|
@ -1256,7 +1256,6 @@ rb_proc_exec(const char *str)
|
||||||
enum {
|
enum {
|
||||||
EXEC_OPTION_RLIMIT,
|
EXEC_OPTION_RLIMIT,
|
||||||
EXEC_OPTION_ENV,
|
EXEC_OPTION_ENV,
|
||||||
EXEC_OPTION_CHDIR,
|
|
||||||
EXEC_OPTION_DUP2,
|
EXEC_OPTION_DUP2,
|
||||||
EXEC_OPTION_CLOSE,
|
EXEC_OPTION_CLOSE,
|
||||||
EXEC_OPTION_OPEN,
|
EXEC_OPTION_OPEN,
|
||||||
|
@ -1281,6 +1280,7 @@ mark_exec_arg(void *ptr)
|
||||||
rb_gc_mark(eargp->envp_str);
|
rb_gc_mark(eargp->envp_str);
|
||||||
rb_gc_mark(eargp->envp_buf);
|
rb_gc_mark(eargp->envp_buf);
|
||||||
rb_gc_mark(eargp->dup2_tmpbuf);
|
rb_gc_mark(eargp->dup2_tmpbuf);
|
||||||
|
rb_gc_mark(eargp->chdir_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1622,12 +1622,12 @@ rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val)
|
||||||
eargp->unsetenv_others_do = RTEST(val) ? 1 : 0;
|
eargp->unsetenv_others_do = RTEST(val) ? 1 : 0;
|
||||||
}
|
}
|
||||||
else if (id == rb_intern("chdir")) {
|
else if (id == rb_intern("chdir")) {
|
||||||
if (!NIL_P(rb_ary_entry(options, EXEC_OPTION_CHDIR))) {
|
if (eargp->chdir_given) {
|
||||||
rb_raise(rb_eArgError, "chdir option specified twice");
|
rb_raise(rb_eArgError, "chdir option specified twice");
|
||||||
}
|
}
|
||||||
FilePathValue(val);
|
FilePathValue(val);
|
||||||
rb_ary_store(options, EXEC_OPTION_CHDIR,
|
eargp->chdir_given = 1;
|
||||||
hide_obj(rb_str_dup(val)));
|
eargp->chdir_dir = hide_obj(rb_str_dup(val));
|
||||||
}
|
}
|
||||||
else if (id == rb_intern("umask")) {
|
else if (id == rb_intern("umask")) {
|
||||||
mode_t cmask = NUM2MODET(val);
|
mode_t cmask = NUM2MODET(val);
|
||||||
|
@ -2818,15 +2818,14 @@ rb_execarg_run_options(const struct rb_execarg *eargp, struct rb_execarg *sargp,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
obj = rb_ary_entry(options, EXEC_OPTION_CHDIR);
|
if (eargp->chdir_given) {
|
||||||
if (!NIL_P(obj)) {
|
|
||||||
if (sargp) {
|
if (sargp) {
|
||||||
char *cwd = my_getcwd();
|
char *cwd = my_getcwd();
|
||||||
rb_ary_store(sargp->options, EXEC_OPTION_CHDIR,
|
sargp->chdir_given = 1;
|
||||||
hide_obj(rb_str_new2(cwd)));
|
sargp->chdir_dir = hide_obj(rb_str_new2(cwd));
|
||||||
xfree(cwd);
|
xfree(cwd);
|
||||||
}
|
}
|
||||||
if (chdir(RSTRING_PTR(obj)) == -1) { /* async-signal-safe */
|
if (chdir(RSTRING_PTR(eargp->chdir_dir)) == -1) { /* async-signal-safe */
|
||||||
ERRMSG("chdir");
|
ERRMSG("chdir");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue