Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!leah!itsgw!brspyr1!tim From: tim@brspyr1.BRS.Com (Tim Northrup) Newsgroups: comp.unix.wizards Subject: Proper way to detach from control terminal? Keywords: detach control-terminal setpgrp Message-ID: <5333@brspyr1.BRS.Com> Date: 27 Jan 89 21:45:28 GMT Organization: BRS Information Technologies, Latham NY Lines: 46 I would like to know if there is a "proper" way to detach a process from its control terminal (once it has fork'ed and the parent has terminated). I have seen a couple of different ways of doing this and would like to know which ones work, which don't, if there are any others, and which is the correct way to do it. Here are the methods I have seen: 1. setpgrp(2) This is the method described in the System V section termio(7), and does seem to work. The calling sequence I am using is simply setpgrp() for System V and setpgrp(0,getpid()) for BSD based code. But, on BSD systems, the control terminal is still reported when a ps(1) is done. Under System V, the control tty is listed as '?', as I would expect. Is there any way to get this behavior under BSD? 2. ioctl(...TIOCSPGRP...) Is using ioctl to set the process group any different than using the setpgrp() system call? 3. ioctl(...TIOCNOTTY...) I have seen this used in the recently posted plp software, but cannot find any documentation on this setting other than "void tty association" in the header file on a BSD system. 4. closing all terminal files I don't know if I am reading things wrong, but it seems that some programs simple close stdin/stdout/stderr on startup and open something else as stdin. Does this really do anything? Should I do this in concert with any/all of the above options? Thanks in advance for any assistence. -- Tim -- Tim Northrup +------------------------------------------+ +---------------------------------+ GEnie: T.Northrup | UUCP: uunet!steinmetz!brspyr1!tim | Air Warrior: "Duke" | ARPA: tim@brspyr1.BRS.Com +------------------------------------------+