ipmon fills up partition

Matthew Seaman m.seaman at infracaninophile.co.uk
Sat Apr 17 11:19:03 PDT 2004

On Sat, Apr 17, 2004 at 06:31:24PM +0200, Melvyn Sopacua wrote:
> On Saturday 17 April 2004 18:00, Matthew Seaman wrote:
> > > Adding /var/run/ipmon.pid at the end of newsyslog.conf line above stops
> > > the above symptom, but ipmon stopped logging after each rotation.
> >
> > This should be the correct thing to do: ipmon should interpret a HUP
> > signal to mean 'reopen log files' -- unless it's changed dramatically
> > between 4.x and 5.x[*], in which case you'll have to hunt down what
> > should be done instead by reading the documentation or the code or
> > something.
> It does:
> ipmon.c:1452
>                        if (donehup) {
>                                 donehup = 0;
>                                 if (newlog) {
>                                         fclose(log);
>                                         log = newlog;
>                                         newlog = NULL;
>                                 }
>                         }
> And:
> static void handlehup(sig)
> int sig;
> {
>         FILE    *fp;
>         signal(SIGHUP, handlehup);
>         if (logfile && (fp = fopen(logfile, "a")))
>                 newlog = fp;
>         init_tabs();
>         donehup = 1;
> }
> The only codepath I can see, that could cause this behavior, would be if the 
> fopen fails, because newsyslog is holding a lock on the file at the time it 
> signals ipmon.

Yes.  It's not obvious what's wrong.  However, if donehup is non-zero,
and logfile is not NULL but newlog is still NULL, then the fopen() in
the signal handler must have failed -- and it should be quite simple
to track that in a debugger or instrument the code to show that is
what's happening.  If it had failed, then the logging data would still
go to the old log file, but that's not what was observed.

I kind of wonder why it opens the new logfile, reallocates and
populates a bunch of lookup tables in the signal handler, but then
waits until the next time round main event loop to actually close the
old logfile and switch to the newly opened logfile for writing the log
data to.  Why not leave the logfile open to the main loop as well? But
I'm no expert on these things.



Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20040417/4d42aa46/attachment.bin

More information about the freebsd-questions mailing list