Xref: utzoo comp.unix.wizards:22370 comp.bugs.4bsd:1565 Path: utzoo!attcan!uunet!snorkelwacker!bu.edu!orc!decwrl!sgi!rpw3@rigden.wpd.sgi.com From: rpw3@rigden.wpd.sgi.com (Rob Warnock) Newsgroups: comp.unix.wizards,comp.bugs.4bsd Subject: Re: more BSD strangeness -- syslogd.c Message-ID: <61921@sgi.sgi.com> Date: 8 Jun 90 13:08:50 GMT References: <1990Jun8.070904.7466@athena.mit.edu> Sender: rpw3@rigden.wpd.sgi.com Reply-To: rpw3@sgi.com (Rob Warnock) Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 39 In article <1990Jun8.070904.7466@athena.mit.edu> jik@athena.mit.edu (Jonathan I. Kamens) writes: +--------------- | Here's another little gem of code from BSD4.3 that I don't quite | understand. Pulled from etc/syslogd.c: | if (!Debug) { | if (fork()) | exit(0); | 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? +--------------- Just guessing, but... Because /dev/null might not be there. Or might have been removed and now /dev/null is a *plain* file, not a special. [Oh, boy, that can make things weird!] Or somebody may have mounted a funny file system on /dev. Or the kernel may have been reconfigured and recompiled and the major i-node numbers changed and nobody has run MAKEDEVS to fix 'em all up yet so the device under "/dev/null" isn't /dev/null. [Yup! Seen *that* one, too!] But if the system booted at all, "/etc/init" was there, so "/" is there. And the i-node number for "/" is stored in memory. -Rob ----- Rob Warnock, MS-9U/510 rpw3@sgi.com rpw3@pei.com Silicon Graphics, Inc. (415)335-1673 Protocol Engines, Inc. 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311