On 3/25/06, Tom Allison wrote:
If I have a cgi script that send text/plain what does the client see if I send
all the text at once but then don't exit for seconds because I'm doing some
background processing at my end? do they sit and spin around in circles?
What happened when you tried it?
If you want to do some background processing without tying up the
client, you'll probably want your webserver to think that you're all
finished. One way to do that is to fork a child process and let the
parent quit. If the child then closes the output filehandles STDOUT
and STDERR, the webserver should conclude that the CGI program has
finished, even though the child process is still running.
Instead of simply closing the output filehandles, you could reopen
them, with the output going to a file (or even /dev/null). In Perl,
it's generally better to reopen the standard filehandles like that
rather than closing them, so that new filehandles will be properly
numbered internally. The important thing is that the webserver sees
that nobody is writing to it any longer, since the filehandles are
closed, so it can reply to the remote user.
Hope this helps!
Stonehenge Perl Training