Why not write the application around a queue?

You write out a page with a stop button on submit, if it is "pressed", it pushes a stop command at the queue, and after certain process points, your script checks to see if it should stop, or you have a child that looks for the stop. This way, you aren't relying on catching the "Stop" button.

The constant writing to STDOUT isn't always a good method. Example:

Our intranet has a throttle, and will also time out connections that last longer than X minutes if the connection is going between buildings. Meanwhile, your CGI script is running, but the STOP button on the browser has been rendered useless.

The Web is stateless, don't try to circumvent that. Writing the queue also allows you to update a percent finished or some other kind of process flag to provide feedback to your user. Put a meta refresh on the page, and the user now has an idea of WHEN the process will finish, based on this feed back without even having to hit an 'update' button (which you SHOULD provide so that an impatient user can always clickity-click). Voila, a stateful looking connection to a stateful application in a stateless medium.

C-.

Update: After reading the above, I realized that my writing looks like I haven't slept in days. It's catching up to me.


In reply to Re: Detect Stop Button by cacharbe
in thread Detect Stop Button by hakkr

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.