Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!cs.utexas.edu!helios!auvc6!auvhess From: auvhess@auvc6.tamu.edu (David K. Hess) Newsgroups: comp.unix.wizards Subject: Re: Daemonizing question... Keywords: daemon, open Message-ID: <12497@helios.TAMU.EDU> Date: 22 Feb 91 18:00:12 GMT References: <12459@helios.TAMU.EDU> Sender: usenet@helios.TAMU.EDU Reply-To: auvhess@auvc6.tamu.edu (David K. Hess) Followup-To: comp.unix.wizards Organization: Texas A&M University Lines: 24 Thanks to Jonathan Kamens and Xing Wu for the answer to this one. Due to two requests for the answer I'm posting it here. > fork() > close(open descriptors) > open("/") > dup(0) > open("/dev/tty") > ioctl(tty,TIOCNOTTY) The reason for the open("/") and dup(0) steps is so that any eventual child process that might be fork()-exec()'d off has valid file descriptors 0, 1, and 2 to play with and still not have a controlling terminal. The reason "/" is used is historical. Apparently when the daemonizing code was written "/dev/null" (a more likely candidate) was not gauranteed to exist under all flavors of Unix (may still not for all I know ;-). Thanks for the help. Dave Hess Graduate Student Texas A&M University auvhess@auvsun1.tamu.edu Brought to you by Super Global Mega Corp .com