Parent document is top of "FAQ: Frequently Asked Questions about CGI Programming"
Previous document is "3.5 Can I trace where a user has come from/is going to?"
Next document is "3.7 Can I launch a long process which the user interacts with?"

3.6 Can I launch a long process and return a page before it's finished?

[UNIX]
You have to fork/spawn the long-running process.
The important thing to remember is to close all its file descriptors;
otherwise nothing will be returned to the browser until it's finished.
The standard trick to accomplish this is redirection to/from /dev/null:

        exec ("long_process < /dev/null > /dev/null 2>&1 &")
        print HTML page as usual

Parent document is top of "FAQ: Frequently Asked Questions about CGI Programming"
Previous document is "3.5 Can I trace where a user has come from/is going to?"
Next document is "3.7 Can I launch a long process which the user interacts with?"