From: Jim C. <jc...@di...> - 2003-08-05 20:46:02
|
msc...@ao... wrote: >Hey, > >just had an idea: How about if we add functionality to init_and_watch in Log::Log4perl to not only watch config files but to also be able to listen to (Unix) signals instead? Yeah, yeah, I know signals are unreliable and can cause all kinds of crazy stuff -- but how about if we have the signal handler just set a global variable, which is checked by the watcher code instead of calling time() all the time? >Please take a look at the patch below, and let me know what you think ... the addtl. syntax is: > > init_and_watch($file, 'HUP'); # will listen to SIGHUP > >I've also attached a test file. > >-- Mike > > > Ive only glanced at patch, so this might be done already (or might be stupid - I havent thought it thru) does patch allow user to use ALRM to duplicate existing behavior. consistency would dictate that this is a good idea. in lib/Log/Log4perl/Config/Watch.pm new() sets the signal handler itself, its probly prudent to document this IN LARGE LETTERS. also, since the handler is set there, theres no opportunity to restart the alarm. any point to saving prior signal handler, and maybe even calling it after setting SIGNAL_CAUGHT ? also FWIW - 5.8.0 has safe signals by default, earlier doesnt. there may be some suprises in there. |