If you haven't already, read perldoc perlipc for information of setting up signal handlers using %SIG. The HUP, USR1, and USR2 signals are good candiates. The usual idiom is to have the handler set a flag, and then you check that flag in your main loop.
my $reload_config = 0; $SIG{USR1} = sub { $reload_config = 1 }; ... while( $yadda_yadda_yadda ) { check_something( $something ); poll_for_widgets( $mywidgets ); if( $reload_config ) { reload_my_config( $config ); $reload_config = 0; } }
As for sending interrupts from the keyboard, you're pretty much limited to INT, QUIT, and TSTP as far as what you can send from the keyboard with a plain tty driver. Usually stty -a will give a list of what keys will send what particular signal. For example here's what I get on Linux (YDL 2.0 PPC):
speed 38400 baud; rows 30; columns 80; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = + ^W; ...
Ctrl-c will send SIGINT, Ctrl-\ will send SIGQUIT, and Ctrl-z sends SIGTSTP. You can't really send other signals (USR1, HUP, et al) easily from the keyboard, but you can always have your program write out its PID to a file and then use backticks in your shell to do kill -HUP `cat /var/run/myprog.pid`.
You may also want to look into Event or POE, both of which provide ways of triggering events in your program when signals are received.
In reply to Re: Using traps to autoincrement / decrement variables
by Fletch
in thread Using traps to autoincrement / decrement variables
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |