* test/ruby/envutil.rb (EnvUtil#invoke_ruby): change the

environment of spawned process only.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-06-25 00:58:57 +00:00
parent 9f16d373f3
commit fdf5a3dd8d
2 changed files with 9 additions and 13 deletions

View File

@ -1,4 +1,7 @@
Fri Jun 25 09:56:39 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> Fri Jun 25 09:58:32 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* test/ruby/envutil.rb (EnvUtil#invoke_ruby): change the
environment of spawned process only.
* test/ruby/envutil.rb (EnvUtil#invoke_ruby): get rid of possible * test/ruby/envutil.rb (EnvUtil#invoke_ruby): get rid of possible
deadlock. deadlock.

View File

@ -69,9 +69,6 @@ module EnvUtil
in_c, in_p = IO.pipe in_c, in_p = IO.pipe
out_p, out_c = IO.pipe if capture_stdout out_p, out_c = IO.pipe if capture_stdout
err_p, err_c = IO.pipe if capture_stderr err_p, err_c = IO.pipe if capture_stderr
c = "C"
env = {}
LANG_ENVS.each {|lc| env[lc], ENV[lc] = ENV[lc], c}
opt = opt.dup opt = opt.dup
opt[:in] = in_c opt[:in] = in_c
opt[:out] = out_c if capture_stdout opt[:out] = out_c if capture_stdout
@ -80,11 +77,14 @@ module EnvUtil
out_p.set_encoding(enc) if out_p out_p.set_encoding(enc) if out_p
err_p.set_encoding(enc) if err_p err_p.set_encoding(enc) if err_p
end end
c = "C"
child_env = ENV.dup
LANG_ENVS.each {|lc| child_env[lc] = c}
case args.first case args.first
when Hash when Hash
child_env = [args.shift] child_env.update(args.shift)
end end
pid = spawn(*child_env, EnvUtil.rubybin, *args, opt) pid = spawn(child_env, EnvUtil.rubybin, *args, opt)
in_c.close in_c.close
out_c.close if capture_stdout out_c.close if capture_stdout
err_c.close if capture_stderr err_c.close if capture_stderr
@ -103,13 +103,6 @@ module EnvUtil
Process.wait pid Process.wait pid
status = $? status = $?
ensure ensure
env.each_pair {|lc, v|
if v
ENV[lc] = v
else
ENV.delete(lc)
end
} if env
in_c.close if in_c && !in_c.closed? in_c.close if in_c && !in_c.closed?
in_p.close if in_p && !in_p.closed? in_p.close if in_p && !in_p.closed?
out_c.close if out_c && !out_c.closed? out_c.close if out_c && !out_c.closed?