Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uunet!auspex!hitz From: hitz@auspex.auspex.com (Dave Hitz) Newsgroups: comp.unix.wizards Subject: Re: more BSD strangeness -- syslogd.c Message-ID: <3446@auspex.auspex.com> Date: 9 Jun 90 21:31:59 GMT References: <1990Jun8.070904.7466@athena.mit.edu> <36447@sequent.UUCP> Organization: Auspex Systems, Santa Clara Lines: 28 djm@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