[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[leafnode-list] Ever wanted to change the verbosity level of a running fetchnews?



I've occasionally wanted to change the verbosity level of a running
fetchnews process, typically because its taking a long time in a
newsgroup, and I want to see that it is still working... I usually run
fetchnews from the 'ip-up' script that is run when a pppd connection
comes up, and send the debug output to a file - which I then 'tail -f'
if I want to watch what is happening. However, since I normally don't
need lots of detail, the fetchnews invocation in ip-up only has a
single '-v'.

Without killing the process and running the danger of losing news, I
wanted to change verbosity levels on the fly, so I added the following
code (context diff against the fetchnews.c in leafnode-1.9.12):

***************
*** 90,93 ****
--- 90,105 ----
  #endif
  
+ static void catch_sig_usr( int signo )
+ {
+     if (signo == SIGUSR1)
+     {
+         verbose++;
+     }
+     else if (signo == SIGUSR2)
+     {
+         verbose--;
+     }
+ }
+ 
  static void sig_int( int signo ) {
      if ( signo == SIGINT || signo == SIGTERM )
***************
*** 1596,1599 ****
--- 1608,1622 ----
      }
  
+     if ( signal( SIGUSR1, catch_sig_usr ) == SIG_ERR )
+     {
+         fprintf(stderr, "Can't catch SIGUSR1.\n");
+         exit(-1);
+     }
+     if ( signal( SIGUSR2, catch_sig_usr ) == SIG_ERR )
+     {
+         fprintf(stderr, "Can't catch SIGUSR2.\n");
+         exit(-1);
+     }
+     
      while ( servers ) {
        current_server = servers;

Now, if you send SIGUSR1 to fetchnews, verbosity goes up by one, and
if you send SIGUSR2, it goes down by one. This code is a bit kludgy -
exiting if you can't catch the signals, for instance - but basically
does what I want it to. Posting here in case anyone else finds this
useful.

Cheers

Colin

----------------------------------------------------------------------
Colin Brough                               Colin.Brough@xxxxxxxxxxxxxx

-- 
leafnode-list@xxxxxxxxxxxxxxxxxxxxxxxxxxxx -- mailing list for leafnode
To unsubscribe, send mail with "unsubscribe" in the subject to the list