Last week there was much discussion (some of it even on topic :) about
making multilog rotate files on receipt of a signal.

Here's my very simple patch to make multilog rotate its current file
on receipt of SIGHUP. I have tested it under RedHat Linux 6.2 ONLY.
However, as I have used Dan's coding style (all 2 lines of it) it
should work under any systems on which multilog currently works.

My tests were fairly minimal - I hammered multilog as fast as I could
and sent it a SIGHUP. I then checked to see if it lost any data
between rotations - it didn't.

It obviously needs field testing, but I think it will allow us to
rotate based on time. All we need is a cron job to send the SIGHUP at
the appropriate time.

If you use this, please let me know how it goes. If I get positive
feedback (or no feedback at all) I'll release it in the same manner as
my tai64nunix package - ie a stripped down daemontools with only enough
to build the new multilog. This should comply with Dan's licensing
rules.

-- 
Regards
Peter
----------
Peter Samuel                            [EMAIL PROTECTED]
http://www.e-smith.org (development)    http://www.e-smith.com (corporate)
Phone: +1 613 368 4398                  Fax: +1 613 564 7739
e-smith, inc. 1500-150 Metcalfe St, Ottawa, ON K2P 1P1 Canada

"If you kill all your unhappy customers, you'll only have happy ones left"
--- multilog.c.orig     Mon Mar  6 00:21:09 2000
+++ multilog.c  Tue Oct 10 12:29:42 2000
@@ -243,6 +243,11 @@
   }
 }
 
+void rotate(void)
+{
+  fullcurrent(c);
+}
+
 int c_write(int pos,char *buf,int len)
 {
   struct cyclog *d;
@@ -561,6 +566,7 @@
   coe(fdstartdir);
 
   sig_catch(sig_term,exitasap);
+  sig_catch(sig_hangup,rotate);
 
   ++argv;
   f_init(argv);

Reply via email to