more BSD strangeness -- syslogd.c

Rene' Seindal seindal at skinfaxe.diku.dk
Mon Jun 11 21:49:20 AEST 1990


hitz at auspex.auspex.com (Dave Hitz) writes:

> This answers the question "why close all open files", but it doesn't
> answer the question, "why open anything at all for descriptors 0, 1 and
> 2."  If it makes no reference to stdin, stdout, stderr, why must there
> be something open for them?

Because otherwise those file descriptors will be used for something
else, such as log files or sockets, contrary to the usual conventions
abount what the file descriptors 0, 1 and 2 means.

> I can (and have) made up several answers for this.  Anyone know the real
> one?  What happens if you just leave the descriptors closed?

By Murphys Law, some braindead library routine will inevitably write
stupid error messages in your log files or screw up the protocols you
implement on top of a socket, that just happens to be file descriptor 2!
Not an easy one to track down, and a lot of wasted time doing just that.

Rene' Seindal (seindal at diku.dk)



More information about the Comp.unix.wizards mailing list