From: Adam Dickmeiss Date: Tue, 16 Mar 2010 15:14:44 +0000 (+0100) Subject: Close files in CGI child to close bind sock X-Git-Tag: v1.1.2~6 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=324f6dcf90e165c4f8e8b8bfda9ed12b7c5d5582;p=metaproxy-moved-to-github.git Close files in CGI child to close bind sock --- diff --git a/etc/cgi.sh b/etc/cgi.sh index 2fbc75e..478152c 100755 --- a/etc/cgi.sh +++ b/etc/cgi.sh @@ -3,5 +3,5 @@ echo "Content-Type: text/plain" echo "" echo "hello, world." -sleep 5 +sleep 35 diff --git a/src/filter_cgi.cpp b/src/filter_cgi.cpp index 3747e63..3412ca8 100644 --- a/src/filter_cgi.cpp +++ b/src/filter_cgi.cpp @@ -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);