I am trying to write an application that displays data on the screen, or emails the data to the sender, if there is a lot of data to display. For the email part, I fork off a process so that the child does all the data gathering, while the parent merely displays a message, and is supposed to quit.

But it doesnt. The child does his thing, but the stupid parent keeps waiting for the child to finish.

Anyway, here is my code sample:

# %form is a hash that contains all the values # that the person entered on the form. It is global # IF THE USER SELECTED EMAIL..DO THIS CODE if ($form{attachme} eq "yes") { $query =~ s/(and|or)$//; # Strip off trailing AND/OR my ($values, $pid); if ($pid = fork) { # Send the data by email if option selected # The 'Search Was Successful' note has been moved to # the correct directory on the hard drive # and the script redirects the user to that page. # This is to stop HTTPD from hanging. # users'printvtml is just like vtml'printvtml, EXCEPT that the # Content Type text/html line has been replaced with a Locatio +n header # to redirect the user to the note saying that the email has b +een sent. $form{-nextpage} = "/admin/users/reports/mailview.vtml"; # This is a function that we use to print to the screen. # It is not causing this problem. &users'printvtml($URLPREFIX."$form{-nextpage}",\%form,\%script +); exit (0); } elsif (defined $pid) { # CHILD PROCESS GOES HERE if ( $form{which} eq "custom" ) { $values = $form{retval}; } elsif ( $form{which} eq "all" ) { $values = $form{allval}; } exec ("perl $fork_to $form{sendto} \"$query\" $values"); exit (0); } exit (0); }

Edit by tye


In reply to How do you tell the parent process to stop it's HTTP transfer, when it forks off a child process? by kleinbiker7

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.