about summary refs log tree commit homepage
path: root/extras/exec_cgi.rb
diff options
context:
space:
mode:
Diffstat (limited to 'extras/exec_cgi.rb')
-rw-r--r--extras/exec_cgi.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/extras/exec_cgi.rb b/extras/exec_cgi.rb
index 083047e..170e773 100644
--- a/extras/exec_cgi.rb
+++ b/extras/exec_cgi.rb
@@ -67,7 +67,8 @@ class ExecCgi
     PASS_VARS.each { |key| val = env[key] and cgi_env[key] = val }
     env.each { |key,val| cgi_env[key] = val if key =~ /\AHTTP_/ }
     pipe = MyIO.pipe
-    pipe[0].my_pid = Process.spawn(cgi_env, *@args,
+    errbody = pipe[0]
+    errbody.my_pid = Process.spawn(cgi_env, *@args,
                                    out: pipe[1], close_others: true)
     pipe[1].close
     pipe = pipe[0]
@@ -100,9 +101,12 @@ class ExecCgi
           pipe.chunked = true
         end
       end
+      errbody = nil
       [ status, headers, pipe ]
     else
       [ 500, { "Content-Length" => "0", "Content-Type" => "text/plain" }, [] ]
     end
+  ensure
+    errbody.close if errbody
   end
 end