Hi Monks, Wisdom needed. I have this code that uses a fork so that the parent will display a web message stating the request is being processed. Below is the code that I'm having problems with.
} elsif ($url = $cgi->param('url')) { $session = get_session_id(); $cache = get_cache_handle(); $cache->set($session, [0, ""]); #getting the parameters from the cgi object $type = $cgi->param('type'); $mudpit = $cgi->param('mudpit'); $url = $cgi->param('url'); $boldRed = $cgi->param('bold_red'); $maxHits = $cgi->param('max_hits'); if ($pid = fork) { $cgi->delete_all(); $cgi->param('session', $session); print $cgi->redirect($cgi->self_url()); } elsif (defined $pid) { close STDOUT; ($tmpDir, $resDir) = chk_dir($path); $buf = ""; @urlList = split /\n/, $url; foreach (@urlList) { ($link, $fn) = which_svr($_); dl_file($link, $fn, $tmpDir); $buf .= "$fn\n"; $cache->set($session, [0, $buf]); } #$cache->set($session, [1, $buf]); exit; } else { die "Cannot fork: $!"; }
It seems my fork isn't working very well. The process seems to have to complete before anything is shown on the webpage. The webpage display part is below
if ($session = $cgi->param('session')) { $cache = get_cache_handle(); $data = $cache->get($session); print $cgi->header, $cgi->start_html( -title => 'Extract peptide masses', -style => { src => '/stylesheet.css' }, ($data->[0] ? () : (-head => ["<meta http-equiv=re +fresh content=5>"])) ); #generate HTML document start print '<img src="/icons/title_banner.gif">'; print << 'HTML_END' unless $data->[0]; <h3> <p>The system is now getting the required file(s) and extracti +ng the required information.</p> <p>Please do not close this browser.</p> <p>Links to the result(s) will be displayed when the process i +s done.</p> </h3> HTML_END print $cgi->pre($cgi->escapeHTML($data->[1])); print $cgi->end_html;
I have $|=1 in my codes. Can anyone tell me what to do to allow the "hold on" page to be displayed while the process the running? Thanks. Desmond

In reply to fork problem by sandrider

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.