Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!brl-adm!brl-smoke!smoke!bogstad@hopkins-eecs-bravo.arpa From: bogstad@hopkins-eecs-bravo.arpa (William J. Bogstad) Newsgroups: net.unix-wizards Subject: Re: Conventional daemons Message-ID: <2131@brl-smoke.ARPA> Date: Thu, 27-Mar-86 03:05:46 EST Article-I.D.: brl-smok.2131 Posted: Thu Mar 27 03:05:46 1986 Date-Received: Sat, 29-Mar-86 16:19:14 EST Sender: news@brl-smoke.ARPA Lines: 29 Keith Packard says: >In article <261@bu-cs.UUCP> ccc@bu-cs.UUCP (Cameron Carson) writes: >> int s; >> for (s = 0; s < SOME_NUM; s++) >> (void) close(s); >> (void) open("/",0); >> (void) dup2(0,1); >> (void) dup2(0,2); >>My question is: why open "/" ? Why not open something a little >>less vital like, say, /dev/null? > >Well, I suspect the answer to this lies in the dim dark past when unix >ran on small machines. The inode for "/" is always in memory, the >inode for "/dev/null" is only in memory when it is referenced. > ... Useful when your system only has 50 or so incore inodes ... Also, opening, "/" is not dangerous. No one - not even root - can write on a directory. At least on 4.2BSD, you can't even open a directory for writting. So your daemon might use the directory for its standard input but can't do any damage. In addition, "/" is always there. "/dev/null" might not be there on a slightly trashed filesystem. If "/" is gone you can't even boot. A daemon you might run under those conditions is "update" the sync() daemon. Bill Bogstad {umcp-cs!jhunix allegra}!hopkins!bogstad bogstad@hopkins-eecs-bravo.arpa