How to run a program from CGI, without waiting for it to finish

I've run into interesting problem: I needed to run an external program from CGI script, without waiting for it to finish execution (Browser would simply timeout if I did). However, simple fork/exec sequence didn't work - everything was fine, and my CGI would procede all the way through the end, but wouldn't release the connection, and would wait untill program is done. The solutions turned out to be to close stdin/stdout/stderr. Actually, closing stdout would probably be enough, but it is still a good idea to redirect stderr to some other place.