You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apache-bugdb@apache.org by Lance Riley <la...@aeat.co.uk> on 1997/08/28 13:50:03 UTC

mod_cgi/1068: CGI progs do not end until children exit - parent exits to zombie status

>Number:         1068
>Category:       mod_cgi
>Synopsis:       CGI progs do not end until children exit - parent exits to zombie status
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    apache (Apache HTTP Project)
>State:          open
>Class:          sw-bug
>Submitter-Id:   apache
>Arrival-Date:   Thu Aug 28 04:50:02 1997
>Originator:     lance.riley@aeat.co.uk
>Organization:
apache
>Release:        1.1.3
>Environment:
Both of:
Lynx OS 2.2.1
Linux 2.1
>Description:
I am executing a data processing executable which takes some time to complete. 

To get a quick responce the process forks, and the parent then sends the
standard headers, etc and exits. The child is then left to get on with the work.

Run under bash the code executes as expected, with the child being adopted by
init, and the parent terminating completely.

Run as a CGI, the child does the same, but the parent remains as a zombie until
the child exits, at which time the output gets to the browser.
>How-To-Repeat:
Try the following code:

#include <stdio.h>
int main(int argc, char *argv[]) 
        {
        int             pid;                    /*child ID*/
        pid=fork();
        if(pid!=0)      /*PARENT*/
                {
                printf("Content-type: text/html\n\n");
                printf("<html><head></head><body>\n");
                printf("<h1>PARENTAL ZOMBIES 3</h1>\n");
                printf("</body></html>\n");
                exit(0);
                }
        else
                {               /*CHILD*/
                sleep(20);
                exit(0);
                }
        return(0);
        }
>Fix:
I would be interested to know if you have any ideas as to the cause, 
as I cannot see how this can happen. As far as I can see the server 
forks a process, and then uses an exec function to overlay and run the CGI.
I imagin this is also how bash works.

Many thanks for any sugestions
>Audit-Trail:
>Unformatted: