[Mpls-pm] CGI.pm and forking question
Glenn Bushee
glenn at easy-access.com
Mon May 8 11:36:11 PDT 2006
This shouldn't be difficult, but I have to admit that I'm stumped with this
one and would appreciate any advice.
I'm working on a form so that someone can submit data, it gets saved to a
file, and the user gets a nice little thank you screen that goes into a
redirect mode until a forked process completes its analysis of the data.
The problem I'm hitting is that the parent process seems to hang around and
won't invoke the meta redirect until the exec in the child is done. This
doesn't make sense to me.
Here is the snippet:
#!/usr/bin/perl
use CGI qw(:standard);
if (param('submit') ne '') {
my $seq = param('seq');
# $seq gets cleaned up and saved out to a specific location
# fork submitted, start redirecting for polling for results
print header, "<html><head>",
qq~<META HTTP-EQUIV="Refresh"
CONTENT="0;URL=PATH_TO_POLLING_FOR_RESULTS_PROGRAM?refresh=1">~,
"</head><body><h2>Sequence Submitted!</h2>Redirecting
...</body></html>\n";
# double-fork trick because of zombies (got this from some web searching)
unless ($pid = fork) {
unless (fork) {
exec("PATH_TO_ANALYSIS_PROGRAM", "0041"); # 0041 is a hard
coded ARG value for now
exit(0);
}
exit(0);
}
# fork submitted, start redirecting for polling for results
exit(0);
}
Thank you.
- Glenn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/mpls-pm/attachments/20060508/3378c137/attachment.html
More information about the Mpls-pm
mailing list