use File::Temp qw/tempfile/; use CGI; my $q = new CGI; # Get temp file before we fork my (undef, $tempname) = tempfile(OPEN => 0); my $pid = fork; if (not defined $pid) { print $q->header(-status=>'500 Server cutlery malfunction'); exit; } if ($pid) { # Parent. Redirect to display request. # XXX WARNING XXX - This implementation is # very insecure: better off creating a random # string and keying that in your database. print $q->redirect($BASE.'?display_id=' . $tempname); exit; } # ELSE, we're in the child. Run the long-lived command, # saving the result in $tempname. Do not attempt to # send any information directly to the browser.