Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!nrl-cmf!ames!oliveb!3comvax!bridge2!auspex!guy From: guy@auspex.UUCP (Guy Harris) Newsgroups: comp.unix.wizards Subject: Re: Proper way to detach from control terminal? Keywords: detach control-terminal setpgrp Message-ID: <919@auspex.UUCP> Date: 30 Jan 89 19:49:28 GMT References: <5333@brspyr1.BRS.Com> <87445@sun.uucp> Reply-To: guy@auspex.UUCP (Guy Harris) Organization: Auspex Systems, Santa Clara Lines: 21 > /* > * TIOCNOTTY will get rid of my tty & set my pgrp to 0 > */ > ioctl(0, TIOCNOTTY, 0); RU sure? I think TIOCNOTTY only works on "/dev/tty" - it's caught not by the standard line discipline, say, but by the "/dev/tty" driver. >The problem comes when you don't want a ctty but you do want to talk to a tty. >Open() has the unfortunate side effect of handing out cttys' even when you >don't want one. You can do the following in the specified environment: Note that you have to do those operations *after* you've opened the tty in question, and gotten it as a controlling tty; doing it before won't help. >POSIX: > Do a setsid(). Or use the O_NOCTTY flag when opening the tty, which prevents "open" from making it a controlling tty in the first place.