I've got a webpage that sends data to a cgi script. This cgi script posts some of that data to another program that takes a long time to run. I want a webpage to come up saying 'your results will be emailed to you' as soon as the user presses the submit button on the webpage, rather than waiting for the slow program to finish. I thought fork would do it but I've never used it before and I can't get it to work.
A sample of my code is:
if (($FORM{'email'} =~ /\w+\@\w+/)&&($FORM{'sequence'} ne "")){
my $sequence=$FORM{'sequence'};
my $window=$FORM{'window_size'};
my $email=$FORM{'email'};
my $pid = fork();
if($pid==0){ #child process - want this to carry on in background
#call subroutine that posts this info to slow-running program
&get_disorder($sequence, $window, $email);
}
else{ #parent process - want to give use back a webpage NOW
print "Your results will be emailed to you.";
}
}
This has no effect at all - it's still waiting for the slow-running program to before displaying 'your results will be emailed to you'. What am I doing wrong?
I also keep seeing things about zombie children but I'm not clear how to prevent them.
Thanks!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.