To alleviate this problem, I would like to use fork(), so that a parent
process notifies the user that the report will be e-mailed, while a
detached child process generates and sends the report.
However, it appears that even without a "wait" command, my Apache web
server keeps the parent process alive until the child finishes running.
I'd like to know how to stop the parent process from waiting for the
child to finish. I've read quite a bit about using a "double-fork"
solution for this, but I've yet to find a clear example.
Here is a simplified version of the code as I currently have it:
pid_t pid, sid;
pid = fork();
/* Child Process */
if ( pid == 0 ) {
sid = setsid();
if ( sid < 0 )
exit(-1); /* Exit with failure */
/* Code for Report Generation Goes Here */
exit(0);
/* Parent Process: prints HTML notification with CGIC library */
} else if ( pid > 0 ) {
cgiHeaderContentType("text/html");
fprintf(cgiOut, "<html><body>\n");
fprintf(cgiOut, "<p>The report will be e-mailed.</p>\n");
fprintf(cgiOut, "</body></html>\n");
fclose(cgiOut);
_exit(0);
}
Any help or resource suggestions would be greatly appreciated.
Thanks in advance,
Chad Vice
--
PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
SELF-MODERATED newsgroup. aa.net and boutell.com are
NOT the originators of the articles and are NOT responsible
for their content.
HOW TO POST to comp.infosystems.www.authoring.cgi:
http://www.thinkspot.net/ciwac/howtopost.html
You need to close stdin, stdout, and stderr for the child.
Chris