Hi Sarah,

Just to analyse execution:

use CGI qw(:all delete_all escapeHTML); my $redirect_page = "display_page.cgi"; if (my $session = param('session')) { # returning to pick up session # # ...(2) redirect # my $data = $cache->get($session); if ( $data->[0] ){ # # ...(2a) flag set # } else{ # .... } elsif ( (my $slp = param('sleep')) eq 'sleep') { # ....(1) first invocation $cache->set($session, [0, ""]); # no data yet if (my $pid = fork) { # parent does # # ....(1a) fork: parent # print redirect(self_url()); } elsif (defined $pid) { # child does # # ....(1b) fork: child # $cache->set($session, [1, $buf]); exit 0; } else { # .... } } else { # display form # .... } # ....

When processing a cgi request with query parameter sleep eq 'sleep', you get to (2). A child process is forked, then two things happen concurrently:

The flag may, or may not get 'set' prior to get depending on timing (load, task size, scheduling etc..). This might explain why you are sometimes, but not consistantly getting to (2a).


In reply to Re: Issue with Running Long Processes thru CGI by snoopy
in thread Issue with Running Long Processes thru CGI by sara2005

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.