Original content of parent

Ok, let me try to rephrase.

What is the best way to affect program behavior, using keyboard keys/commands/shortcuts/signals, without waiting for user input?

I would like to send keyboard interrupts to a running Perl process to cause it to perform certain functions midstream. For instance, I would like to press ^C and have it dump some information to the screen, I would like to press ^Z and have it dump some information to a file, etc.

To my thinking, it would be easiest to use signals to illicit this behavior from my program especially because it runs in the foreground of a terminal; I am not sure how to send these signals to the program using keyboard controls.
I could use the Linux command 'kill' (and the respective signal number) to send the signals to the process, or I could write a second program and use the Perl built-in 'kill' to send these signals, but this requires a second terminal (which may or may not be feasible) and requires knowing the PID of the Perl process (which is leas than ideal). Both of these solutions are less than ideal.

my problem is I can only send the interrupt signal via keyboard keys.
I assure you this is not what I meant... What I was trying to say is: I would like to send the signals via keyboard keys (or combination of keys), my problem is I don't know how. {What you didn't get that?!? I can imagine why... Can't you read minds?}

Perhaps signals aren't the best choice; I am open to other suggestions, but have no idea where to start other than completely rewriting my program using the POE framework...

Thanks for your understanding; I work for a help desk, so I totally understand how painful it can be when someone requests help and provides partial (or less than partial) information.

What is the best way to affect program behavior, using keyboard keys/commands/shortcuts/signals, without waiting for user input?

Do wait for user input, just do your processing in a separate thread.


In reply to Re^3: Sending Signals / Keyboard Interrupts by ikegami
in thread Sending Signals / Keyboard Interrupts by PyrexKidd

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.