Unless the cron job that starts the morning news stream is owned by the same user account that is running httpd on that machine, a CGI process to kill the playback would need root privilege (or at least appropriate sudo permission). And as a web-based interface, that is not an attractive solution.

My first inclination would be to tailor the cron job so that it not only launches the audio stream player, but also watches (say, at 1 or 2 sec intervals) for the presence of a "stop.playback" file in some designated path. (This means the playback has to be launched as a background process, so the main script being run by cron can continue to operate.) Then the web interaction simply consists of creating the "stop.playback" file on demand, and the cron job script, on seeing this file, kills its child playback process, deletes the file, and exits.

(update: assuming it can happen that the child playback finishes normally (or can be said to be "done") before some unrelated CGI action creates the "stop.playback" file, the cron script would need to check for this condition as well, and exit. You probably don't want today's instance to still be running when cron starts tomorrow's instance.)


In reply to Re: CGI Process Control by graff
in thread CGI Process Control by SkipHuffman

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.