[BusyBox] Five copies of syslog

Tomi Ollila Tomi.Ollila at sonera.com
Tue Oct 10 05:34:42 UTC 2000


Monday Oct 9 20:51:23 -0400 2000 Pavel Roskin <proski at gnu.org> wrote:
> Hello, David!
> 
> 
> I spent a lot of time investigating this problem. syslogd children wait
> in read() forever.
> 
> It looks like that syslogd is not informed about UNIX sockets, that have
> been disconnected on the other side.
> 
> It shouldn't be hard to use select() with a timeout but this would hide
> the real question - why doesn't read() return?
> 
> If I remember correctly, I tried select() without timeout and with check
> for error conditions - it didn't help, i.e. select() blocked forever just
> like read().
> 
> I hope that somebody with a good knowledge in UNIX sockets will check
> syslogd for this problem. Maybe GLibc needs to be checked as well.

Well, I have done lot of work with all kind of file descriptors on UNIX, 
files, FIFOs, pipes and both UNIX and INET sockets. And every time
when other end has closed the connection, read() has returned 0. select()
basically uses the same way of notifying when there is "read" event on
a fd available so those should always behave in sync with each other...

I checked the code, and (while there is lot of things I'd like to change ;D)
I noticed nothing wrong how and when that `read()' is called. A new process
is created, and the while -loop functions as long as read returns > 0.

Now. Are you sure, that all the processes that has the syslog fd (or copies 
of it ) open has closed it.

> 
> Regards,
> Pavel Roskin
> 

...

While looking the code I noticed one possible "problem" there.

In remote logging section (sorry, don't know exact location, I'm browsing
the CVS w/ a web browser), there are lines:

	bzero(&res, sizeof(res));
	snprintf(res, sizeof(res), "<%d>", pri);

I'm not sure the exact functional spesification of snprintf -- maybe it
states, that the last byte should always be zero -- but some
implementations may not provide this. Therefore I suggest changing it as:

	snprintf(res, sizeof(res), "<%d>", pri);
	res[sizeof res - 1] = '\0';
	
Tomi





More information about the busybox mailing list