]> granicus.if.org Git - apache/commitdiff
Fix zombie process problem with mod_cgi. This problem was introduced
authorJeff Trawick <trawick@apache.org>
Tue, 6 Jun 2000 05:58:16 +0000 (05:58 +0000)
committerJeff Trawick <trawick@apache.org>
Tue, 6 Jun 2000 05:58:16 +0000 (05:58 +0000)
as part of the "Convert ap_proc_t to a complete type." enhancement.

mod_cgi previously declared a ptr to an ap_proc_t, storage was allocated
by ap_create_process() from the request pool, and the ap_proc_t address
was passed to ap_note_subprocess().

With the "Convert ap_proc_t to a complete type." change, ap_proc_t
lived in autodata, but the address was still passed to
ap_note_subprocess().  When the pool was cleaned up, the ap_proc_t
in autodata had been used for something else, so the contents were
garbage, but pool cleanup needed the contents, especially the os
pid to pass to waidpid().  Since this was garbage, we never reaped
status from the cgi child and thus the cgi child remained a zombie.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85441 13f79535-47bb-0310-9956-ffa450edef68

modules/generators/mod_cgi.c

index 7b4975b7c5f008e65bd06af3b012da09a751cdec..5055a89db3bb2152654fb5ca3d41090eaa35f551 100644 (file)
@@ -301,7 +301,7 @@ static ap_status_t run_cgi_child(BUFF **script_out, BUFF **script_in, BUFF **scr
 {
     char **env;
     ap_procattr_t *procattr;
-    ap_proc_t procnew;
+    ap_proc_t *procnew = ap_pcalloc(p, sizeof(*procnew));
     ap_status_t rc = APR_SUCCESS;
     ap_file_t *file = NULL;
     ap_iol *iol;
@@ -347,7 +347,7 @@ static ap_status_t run_cgi_child(BUFF **script_out, BUFF **script_in, BUFF **scr
                      "couldn't set child process attributes: %s", r->filename);
     }
     else {
-        rc = ap_create_process(&procnew, command, argv, env, procattr, p);
+        rc = ap_create_process(procnew, command, argv, env, procattr, p);
     
         if (rc != APR_SUCCESS) {
             /* Bad things happened. Everyone should have cleaned up. */
@@ -355,10 +355,10 @@ static ap_status_t run_cgi_child(BUFF **script_out, BUFF **script_in, BUFF **scr
                         "couldn't create child process: %d: %s", rc, r->filename);
         }
         else {
-            ap_note_subprocess(p, &procnew, kill_after_timeout);
+            ap_note_subprocess(p, procnew, kill_after_timeout);
 
             /* Fill in BUFF structure for parents pipe to child's stdout */
-            file = procnew.out;
+            file = procnew->out;
             iol = ap_create_file_iol(file);
             if (!iol)
                 return APR_EBADF;
@@ -367,7 +367,7 @@ static ap_status_t run_cgi_child(BUFF **script_out, BUFF **script_in, BUFF **scr
             ap_bsetopt(*script_in, BO_TIMEOUT, &r->server->timeout);
 
             /* Fill in BUFF structure for parents pipe to child's stdin */
-            file = procnew.in;
+            file = procnew->in;
             iol = ap_create_file_iol(file);
             if (!iol)
                 return APR_EBADF;
@@ -376,7 +376,7 @@ static ap_status_t run_cgi_child(BUFF **script_out, BUFF **script_in, BUFF **scr
             ap_bsetopt(*script_out, BO_TIMEOUT, &r->server->timeout);
 
             /* Fill in BUFF structure for parents pipe to child's stderr */
-            file = procnew.err;
+            file = procnew->err;
             iol = ap_create_file_iol(file);
             if (!iol)
                 return APR_EBADF;