Conventional daemons
Joseph S. D. Yao
jsdy at hadron.UUCP
Sun Mar 23 03:15:52 AEST 1986
In article <261 at bu-cs.UUCP> ccc at 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?
For what it's worth, this is exactly what I have done for every
daemon I have had to write or fix. However, "if it ain't broke,
don't fix it." Oh, I do freopen stdout as /dev/console, often.
I hope you meant "/dev/tty" instead of "dev/tty" later on. Also,
a setpgrp() is usually part of this disassociation process.
--
Joe Yao hadron!jsdy at seismo.{CSS.GOV,ARPA,UUCP}
More information about the Comp.unix.wizards
mailing list