If the only real purpose for the fork is so that the message can be displayed, why don't you just display the message in a form, and then go do the long operation single threaded. When the long operation finishes, continue to output to the same page and use some javascript to change the contents of the form field where it says please wait.
I wrote a web based chat over a year ago that makes use of the fact that if you specify a large value in the file size header, the browser will stay connected for quite a while. I can output posted messages to the browser and it will display them as they come. It will just patiently wait there with its busy indicator showing, but it works fine. If you experience timeout problems, just output a blank space character every 3 seconds or so. This will not change anything, as the text is being set via html rendering, sso spaces don't count. If, on the other hand, you really need to fork a background task, you may be thwarted by the apache perl cgi module that keeps the perl interpreter in apache instead of forking a new perl for every cgi script. I do not know if you can fork a background task with perl-cgi-mod or not. James Taylor writes: > I'm working on a cgi script that basically, upon running it, runs a > separate script in the background, and displays a message saying > "Script is running. Should be done soon." on the web browser and... > that's it. The browser can be closed, and the script will continue to > run in the background. Here's the jest of what I have, but... The > problem is that it doesn't work. When you run it, it does a system() > call to run the script, and then waits for completion, where it then > displays "Script is running. Should be done soon.". I tried using > exec() instead but that didn't work either. Also tried adding & to the > end of the command, didn't help. > > #!/usr/bin/perl > use strict; > use CGI qw(:cgi-lib :cgi :html2); > $SIG{CHLD}='IGNORE'; > my $pid=fork(); > if($pid) { > system "/www/scripts/process_list.pl"; # Run script in background > } else { > # Print confirmation script to browser, that's it > print header."<html><body>Script is running. Should be done > soon.</body></html>"; > } > > Any ideas on how to make this work properly?? This is running on > Solaris 8 with apache, if it matters at all. Thanks > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]