relax99 has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
I have a CGI program that takes a long time to save information after a user submits the form. The reason is not that there's a lot of information gathered from the form, but that the program needs to generate this information based on just a few parameters from the user. (It is really a caching feature to pre-generate rarely updated pages and load them from disk instead of constructing the same pages on the fly each time).
What I want to do is to fork a separate process that would deal with saving this information, so that the CGI program can just return the web page and exit. I've tried the code below, but the CGI script still waits for the child to finish saving.
my $pid; if( $pid = fork ){ # parent here # output web page and finish } elsif( defined($pid) ) { # child here # save info and exit exit(0); } else { # fork error }
The Camel Book says that sometimes you have to close open filehandles in the child process before the web server returns the page. I tried closing STDIN, STDOUT and STDERR, but that didn't work.
Perl Cookbook said that I might have to try Win32::Process instead, but I'm not sure if that suits my needs, because I don't need to start a separate standalone process, but just finish saving the information that is shared by both the parent and the child processes.
My system is Windows 2000 running IIS 5. ActivePerl version 5.6.1
Has anyone had any luck with forking on Windows systems? Any sample code or hints or pointers to resources would be highly appreciated!
Thanks!
Alex
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Forking in a CGI program on Windows systems
by Tanalis (Curate) on Nov 08, 2002 at 16:18 UTC | |
by relax99 (Monk) on Nov 08, 2002 at 16:45 UTC | |
|
Re: Forking in a CGI program on Windows systems
by Mr. Muskrat (Canon) on Nov 08, 2002 at 16:20 UTC | |
by relax99 (Monk) on Nov 08, 2002 at 16:53 UTC | |
by Mr. Muskrat (Canon) on Nov 08, 2002 at 17:00 UTC | |
by relax99 (Monk) on Nov 08, 2002 at 19:37 UTC | |
by Mr. Muskrat (Canon) on Nov 08, 2002 at 20:30 UTC | |
|
Re: Forking in a CGI program on Windows systems
by relax99 (Monk) on Nov 08, 2002 at 20:10 UTC | |
by rodnic (Initiate) on Nov 03, 2003 at 22:51 UTC |