Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!sri-spam!ames!oliveb!sun!gorodish!guy From: guy@gorodish.UUCP Newsgroups: comp.unix.wizards Subject: Re: how do I make a process release its terminal? Message-ID: <12572@sun.uucp> Date: Mon, 2-Feb-87 14:58:54 EST Article-I.D.: sun.12572 Posted: Mon Feb 2 14:58:54 1987 Date-Received: Tue, 3-Feb-87 22:14:04 EST References: <118@lmi-angel.UUCP> <323@sol.warwick.ac.uk> Sender: news@sun.uucp Reply-To: guy@sun.UUCP (Guy Harris) Distribution: world Organization: Sun Microsystems, Mountain View Lines: 23 >I would have thought the 'else perror(...);' was undesirable. If you can't >open /dev/tty it probably means you're already without a controlling terminal >and the ioctl is simply unecessary. True. The standard idiom in all the daemons I've seen omits the "perror". You can, instead, check for errno == ENXIO, and only print the error message if it's *not* ENXIO, since the "/dev/tty" driver returns ENXIO if you don't have a controlling terminal. > Don't you want a > > setpgrp(getpid()); > >after that, too, to fully dissociate it from the terminal (otherwise when you >hit ^C, you'll still get the signal). Nope. First of all, "setpgrp" in 4BSD takes two arguments, so it would be setpgrp(0, getpid()); and second, TIOCNOTTY *really* disassociates you from the terminal, so it's not necessary. TIOCNOTTY sets your process group ID to 0.