Hello,

I have a question regarding the best way to run a background process in a web application using CGI and Perl. My best attempt currently forks a parent process which creates a dummy output page (that is set to auto-refresh) and then exits. The child is where I am doing all of my work in my script, and while I know it is rather unorthodox to force the parent to exit before the child, I couldn't figure out another way to accomplish backgrounding within my scripts.

The good part of this solution is that it works; the parent creates an auto-refreshing dummy page, and once the child is done, it overwrites the dummy page with the actual output, and when the dummy page auto-refreshes, it loads the real output and stops refreshing.

The bad part about this solution is that I am unable to incrementally print to the dummy page when my subroutines complete (to show progress in the script). My die statements (for when things like open should fail) are completely hidden however.

I am about to start rewriting all of my dies to print their error message to the dummy page as a work-around, but I feel like there must be a better way than the one I have implemented.

And this brings me to you, oh wise monks, seeking any and all advice you may have about this topic. Thank you in advance.


In reply to CGI Script backgrounding by agronbach

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.