Perl: the Markov chain saw | |
PerlMonks |
Sending Signals / Keyboard Interruptsby PyrexKidd (Monk) |
on Jul 18, 2011 at 21:55 UTC ( [id://915292]=perlquestion: print w/replies, xml ) | Need Help?? |
PyrexKidd has asked for the wisdom of the Perl Monks concerning the following question:
EDIT: Clarification
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.
my problem is I can only send the interrupt signal via keyboard keys. 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. Original Post: Hello Monks,
I understand how to trap signals in Perl, my trouble is with sending the signals. Ideally I would like to be able to press ^C and do something, then ^Z and do something else, my problem is I can only send the interrupt signal via keyboard keys. (as a last choice I can use `kill -* $PID` to send the required signals, but this seems like a poor choice.)
An overtly simplified version of what I am talking about follows: you get the idea.
Back to
Seekers of Perl Wisdom
|
|