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

* process.c (rb_proc_exec_e): extended version of rb_proc_exec() to

call execle().
  (rb_proc_exec): use rb_proc_exec_e().
  (rb_exec_err): use rb_proc_exec_e().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2012-06-03 11:12:20 +00:00
parent 190d319dab
commit 033e2187c6
3 changed files with 35 additions and 7 deletions

View file

@ -1,3 +1,10 @@
Sun Jun 3 20:10:52 2012 Tanaka Akira <akr@fsij.org>
* process.c (rb_proc_exec_e): extended version of rb_proc_exec() to
call execle().
(rb_proc_exec): use rb_proc_exec_e().
(rb_exec_err): use rb_proc_exec_e().
Sun Jun 3 19:47:18 2012 NARUSE, Yui <naruse@ruby-lang.org> Sun Jun 3 19:47:18 2012 NARUSE, Yui <naruse@ruby-lang.org>
* thread.c (vm_living_thread_num): suppress a warning. * thread.c (vm_living_thread_num): suppress a warning.

View file

@ -1160,14 +1160,14 @@ rb_proc_exec_n(int argc, VALUE *argv, const char *prog)
} }
#ifdef __native_client__ #ifdef __native_client__
int static int
rb_proc_exec(const char *str) rb_proc_exec_e(const char *str, VALUE envp_str)
{ {
rb_notimplement(); rb_notimplement();
} }
#else #else
int static int
rb_proc_exec(const char *str) rb_proc_exec_e(const char *str, VALUE envp_str)
{ {
#ifndef _WIN32 #ifndef _WIN32
const char *s = str; const char *s = str;
@ -1210,6 +1210,9 @@ rb_proc_exec(const char *str)
exit(status); exit(status);
#else #else
before_exec(); before_exec();
if (envp_str)
execle("/bin/sh", "sh", "-c", str, (char *)NULL, (char **)RSTRING_PTR(envp_str));
else
execl("/bin/sh", "sh", "-c", str, (char *)NULL); execl("/bin/sh", "sh", "-c", str, (char *)NULL);
preserving_errno(after_exec()); preserving_errno(after_exec());
#endif #endif
@ -1226,7 +1229,7 @@ rb_proc_exec(const char *str)
*a = NULL; *a = NULL;
} }
if (argv[0]) { if (argv[0]) {
ret = proc_exec_v(argv, NULL, Qfalse); ret = proc_exec_v(argv, NULL, envp_str);
} }
else { else {
errno = ENOENT; errno = ENOENT;
@ -1237,6 +1240,12 @@ rb_proc_exec(const char *str)
} }
#endif #endif
int
rb_proc_exec(const char *str)
{
return rb_proc_exec_e(str, Qfalse);
}
enum { enum {
EXEC_OPTION_PGROUP, EXEC_OPTION_PGROUP,
EXEC_OPTION_RLIMIT, EXEC_OPTION_RLIMIT,
@ -2527,7 +2536,7 @@ rb_exec_err(const struct rb_exec_arg *e, char *errmsg, size_t errmsg_buflen)
} }
if (argc == 0) { if (argc == 0) {
rb_proc_exec(prog); rb_proc_exec_e(prog, e->envp_str);
} }
else { else {
rb_proc_exec_ne(argc, argv, prog, e->envp_str); rb_proc_exec_ne(argc, argv, prog, e->envp_str);

View file

@ -309,6 +309,18 @@ class TestProcess < Test::Unit::TestCase
assert_equal(nil, ENV["mgg"], "[ruby-core:44093] [ruby-trunk - Bug #6249]") assert_equal(nil, ENV["mgg"], "[ruby-core:44093] [ruby-trunk - Bug #6249]")
end end
def test_execopts_env_single_word
with_tmpchdir {|d|
open("test_execopts_env_single_word.rb", "w") {|f|
f.puts "print ENV['hgga']"
}
system({"hgga"=>"ugu"}, RUBY,
:in => 'test_execopts_env_single_word.rb',
:out => 'test_execopts_env_single_word.out')
assert_equal('ugu', File.read('test_execopts_env_single_word.out'))
}
end
def test_execopts_unsetenv_others def test_execopts_unsetenv_others
h = {} h = {}
MANDATORY_ENVS.each {|k| e = ENV[k] and h[k] = e} MANDATORY_ENVS.each {|k| e = ENV[k] and h[k] = e}