more BSD strangeness -- syslogd.c

Dave Hitz hitz at auspex.auspex.com
Sun Jun 10 07:31:59 AEST 1990


 djm at eng.umd.edu (David J. MacKenzie) writes:
 >>>               for (i = 0; i < 10; i++)
 >>>                       (void) close(i);
 >>>               (void) open("/", 0);
 >>>               (void) dup2(0, 1);
 >>>               (void) dup2(0, 2);
 >>>               untty();
 >>>OK, so why is it opening "/"?  Is this a poor man's equivalent to
 >>>/dev/null, and if so, why doesn't it just open /dev/null?

 ...

 > syslog wants to make sure that it doesn't hold open any files on
 > stdin, stdout, or stderr that would tie up a filesystem.  I presume
 > that after that it makes no references to stdin, stdout, and stderr.

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?

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

-- 
Dave Hitz					home: 408-739-7116
UUCP: {uunet,mips,sun,bridge2}!auspex!hitz 	work: 408-492-0900



More information about the Comp.unix.wizards mailing list