From f4f28bf75f0aa534de3b1edcf46c8a6ee905e9af Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 3 Jun 2012 08:29:48 +0000 Subject: * use execve() to preserve environment variables when exec method is failed. [ruby-core:44093] [ruby-trunk - Bug #6249] * include/ruby/intern.h (rb_exec_arg): add envp_str and envp_buf field to store envp of execve(). * process.c (proc_exec_v): takes envp_str as an argument and use it for execve(). (rb_proc_exec_ne): extended version of rb_proc_exec_n(). (rb_proc_exec_n): use rb_proc_exec_ne(). (rb_proc_exec): follow proc_exec_v() change. (fill_envp_buf_i): new function. (rb_exec_arg_fixup): set up envp_str and envp_buf. (save_env_i): removed. (save_env): removed. (rb_run_exec_options_err): don't modify environment variables. (rb_exec_err): use rb_proc_exec_ne(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_process.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test/ruby/test_process.rb') diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index 34c1355e58..8bb1b4bb5f 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -303,6 +303,12 @@ class TestProcess < Test::Unit::TestCase end end + def test_execopts_preserve_env_on_exec_failure + ENV["mgg"] = nil + assert_raise(Errno::ENOENT) { Process.exec({"mgg" => "mggoo"}, "/nonexistent") } + assert_equal(nil, ENV["mgg"], "[ruby-core:44093] [ruby-trunk - Bug #6249]") + end + def test_execopts_unsetenv_others h = {} MANDATORY_ENVS.each {|k| e = ENV[k] and h[k] = e} -- cgit v1.2.3