diff options
author | Eric Wong <normalperson@yhbt.net> | 2014-04-20 22:53:43 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2014-04-21 01:24:56 +0000 |
commit | 0432c84f14dc900a1ec0e9e9ccb66a9267437fb3 (patch) | |
tree | 49a185cfa81b2deffba67142805ecea977770315 | |
parent | 95975647c0759f1c141c8627a2826fa8c706258d (diff) | |
download | yahns-0432c84f14dc900a1ec0e9e9ccb66a9267437fb3.tar.gz |
Sometimes a CGI script wants to run with some environment variables set or overridden. Allow it.
-rw-r--r-- | extras/exec_cgi.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/extras/exec_cgi.rb b/extras/exec_cgi.rb index 5eadef8..f718f7b 100644 --- a/extras/exec_cgi.rb +++ b/extras/exec_cgi.rb @@ -65,6 +65,7 @@ class ExecCgi ).map(&:freeze) # frozen strings are faster for Hash assignments def initialize(*args) + @env = Hash === args[0] ? args.shift : {} @args = args first = args[0] or raise ArgumentError, "need path to executable" @@ -80,7 +81,7 @@ class ExecCgi env.each { |key,val| cgi_env[key] = val if key =~ /\AHTTP_/ } pipe = MyIO.pipe errbody = pipe[0] - errbody.my_pid = Process.spawn(cgi_env, *@args, + errbody.my_pid = Process.spawn(cgi_env.merge!(@env), *@args, out: pipe[1], close_others: true) pipe[1].close pipe = pipe[0] |