Conventional daemons

Kent S. Harris ksh at rtgvax.UUCP
Wed Apr 2 08:48:27 AEST 1986


In article <2177 at brl-smoke.ARPA>, bzs%bostonu.csnet at csnet-relay.arpa (Barry Shein) writes:
> 
> ...why do they open "/" on stdin/stdout...
> ...
> The real question was, why open anything? Surely there's
> nothing functionally useful about opening stdin/stdout on
> "/" and it could be a potential hazard if ported.
> ...
Yes, I believe there is.  I've not followed this all the way to ground
state, but I recall deep within the cobwebs something about stdio having
some hard coded constants reguarding fd's < 3 (I know the kernel doesn't
give two hoots about particular fd's).  The idea is to close
all fd's, open "/", and dup this fd to 1 and 2 so any new opens will
be allocated fd's >= 3.  Doing file stream i/o via stdio where an fd < 3
has been allocated seems to send data to ye old bit bucket (empirically
determined).  Let's hear from someone with a definitive answer.



More information about the Comp.unix.wizards mailing list