I wrote a little test script to display my problem (below).
This little script works fine on the command line, meaning you get the folloging :
Ok Parent
back to prompt
10 seconds later
Child (pops up)
which means, it works.
Now, When this script is exeuted by httpd... It prints Ok Parent (and sleeps 10 seconds).
"Child" does not print... it's normal
How do I get the CGI to fork properly under httpd?
----------------------------------
print "Content-type: text/html\n\n";
print "Ok ";
if (fork()) {
# parent process
print "Parent ";
close(STDOUT);
exit;
}
# child process
sleep 10;
print "Child";
----------------------------------
In other words, a child process can't have any output when running as a CGI. If you need to communicate back to the parent, use some method of IPC (unix sockets, shmem, etc)
Sean