Close files in CGI child to close bind sock
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 16 Mar 2010 15:14:44 +0000 (16:14 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 16 Mar 2010 15:14:44 +0000 (16:14 +0100)
etc/cgi.sh
src/filter_cgi.cpp

index 2fbc75e..478152c 100755 (executable)
@@ -3,5 +3,5 @@ echo "Content-Type: text/plain"
 echo ""
 
 echo "hello, world."
-sleep 5
+sleep 35
 
index 3747e63..3412ca8 100644 (file)
@@ -49,7 +49,6 @@ namespace metaproxy_1 {
 
 yf::CGI::CGI() : m_p(new Rep)
 {
-
 }
 
 yf::CGI::~CGI()
@@ -91,11 +90,14 @@ void yf::CGI::process(mp::Package &package) const
             int r;
             pid_t pid;
             int status;
-
+            int fd;
+            
             pid = ::fork();
             switch (pid)
             {
             case 0: /* child */
+                for (fd = 3; fd <= 1023; fd++)
+                    close(fd);
                 setenv("PATH_INFO", path_info.c_str(), 1);
                 setenv("QUERY_STRING", query_string.c_str(), 1);
                 r = execl(it->program.c_str(), it->program.c_str(), (char *) 0);