I am writing a CGI script in Perl. Unfortunately, it is probably going to take several minutes to execute in practice, and it doesn't need to interact with the user while it's doing its business..

Therefore, I was hoping to be able to have the script fork a subprocess to do the hard stuff and then e-mail the user (we already know the user has a valid e-mail address, as this is where their registration stuff was sent).

Am I OK with the following code?

# ..... stuff
print "Content-type: text/html\n\n"; # tell browser to expect HTML document
# ..... more stuff
print "You will receive an e-mail when the task completes.\n</body>\n</html>\n";
exit if fork; # returns PID of spawned process to parent process (which then exits), 0 to child process
# at this point, we must be in the child process
close STDIN;
close STDOUT;
close STDERR;
# now we are detached from the Apache server, so the parent process can die
exec "/usr/local/bin/do_slow_bit";

It's going to be running on a fairly modern Linux, so init doesn't mind dealing with orphans and zombies.
*** EDIT ***

No. The reason why I can't use system is, system always waits for the new process to die. So the script will not move on to the next line as long as the new process is running. Either the Apache server or the browser will sever the connection if the script is taking too long to execute (or the user might think something is wrong and close the page). This will kill off the process before it has finished, and it's something that really can't be left half-done.