def execute_tmpfile(code)
ios = %w[_ stdin stdout stderr]
stdin, stdout, stderr = (1..3).map do |i|
fname = if $DEBUG
"xmpfilter.tmpfile_#{ios[i]}.rb"
else
"xmpfilter.tmpfile_#{Process.pid}-#{i}.rb"
end
f = File.open(fname, "w+")
at_exit { f.close unless f.closed?; File.unlink fname unless $DEBUG}
f
end
stdin.puts code
stdin.close
@stdin_path = File.expand_path stdin.path
exe_line = "$stdout.reopen('\#{File.expand_path(stdout.path)}', 'w')\n$stderr.reopen('\#{File.expand_path(stderr.path)}', 'w')\n$0 = '\#{File.expand_path(stdin.path)}'\nARGV.replace(\#{@options.inspect})\nload \#{File.expand_path(stdin.path).inspect}\n\#{@evals.join(\";\")}\n".map{|l| l.strip}.join(";")
debugprint "execute command = #{(interpreter_command << "-e" << exe_line).join ' '}"
oldpwd = Dir.pwd
@interpreter_info.chdir_proc and @interpreter_info.chdir_proc.call
system(*(interpreter_command << "-e" << exe_line))
Dir.chdir oldpwd
[stdout, stderr]
end