John, thanks for the patch -- the feature you have proposed looks very useful. Indeed, as Mark mentioned, you can change debug level (as other command line options!) dynamically via the SEC resource file, but having a separate signal for this is more handy. I will review the patch and include the new feature into the 2.5.0 release. br, risto
John P. Rouillard wrote: > Hi all: > > In message <496c914c.2020...@seb.ee>, > Risto Vaarandi writes: >> I have released SEC-2.5.beta2 that can be downloaded from: >> http://prdownloads.sourceforge.net/simple-evcorr/sec-2.5.beta2.tar.gz > > I have enclosed a patch that I have found useful. It allows you to > change the SEC debug level dynamically. For each SIGINT that is > received by SEC, the debug level will increment by 1 and wrap around > to 1 if it exceeds 6. > > It is enabled only if STDIN is not a terminal (e.g. it's running as a > daemon, or under nohup etc). > > This is really useful when adding new rules as it stops me from having > to stop and restart SEC (so I don't loose state) when I am debugging a > new ruleset. > > The output in the log if the hander is enabled is: > > Wed Jan 21 13:42:02 2009: Installing SIGINT handler to change debug level. > > and if not enabled (because stdin is a terminal): > > Wed Jan 21 13:43:32 2009: Not installing SIGINT handler to change debug > level. > > and on every kill -INT <pid> > > Wed Jan 21 13:42:26 2009: Int signal received. Debug set to 3 > Wed Jan 21 13:42:43 2009: Int signal received. Debug set to 4 > ... > Wed Jan 21 13:44:27 2009: Int signal received. Debug set to 6 > Wed Jan 21 13:44:28 2009: Int signal received. Debug set to 1 > > Can this be applied to SEC before the next release? > > Thanks. > -- > -- rouilj > John Rouillard > =========================================================================== > My employers don't acknowledge my existence much less my opinions. > > > > > ------------------------------------------------------------------------ > > --- ../sec-2.5.beta2.orig/sec.pl 2009-01-13 07:31:33.000000000 -0500 > +++ sec.pl 2009-01-21 13:34:32.159525300 -0500 > @@ -8055,6 +8055,14 @@ > > } > > +sub int_handler { > + # allow kill -INT to change the debuglevel from 1-6 > + $SIG{INT} = \&int_handler; > + $debuglevel += 1; > + if ($debuglevel > 6) { $debuglevel = 1 }; > + log_msg(LOG_CRIT, "Int signal received. Debug set to $debuglevel"); > +} > + > > # Parameters: - > # Action: on arrival of SIGTERM clean things up and exit > @@ -8352,6 +8360,16 @@ > $openlog = 0; > $SIG{USR2} = \&usr2_handler; > > +# Check to see if we are under control of a terminal > +# If not hijack SIGINT to increment and roll over debug level 1...6 > +# at runtime. > +if (! -t STDIN) { > + $SIG{INT} = \&int_handler; > + log_msg(LOG_CRIT, "Installing SIGINT handler to change debug level."); > +} else { > + log_msg(LOG_CRIT, "Not installing SIGINT handler to change debug level."); > +} > + > $terminate = 0; > $SIG{TERM} = \&term_handler; > > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > > > ------------------------------------------------------------------------ > > _______________________________________________ > Simple-evcorr-users mailing list > Simple-evcorr-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users ------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ Simple-evcorr-users mailing list Simple-evcorr-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users