Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 exptools; site whuxl.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!drutx!mtuxo!houxm!whuxl!mike From: mike@whuxl.UUCP (BALDWIN) Newsgroups: net.unix-wizards Subject: Re: Re: Disassocation from controlling tty Message-ID: <1075@whuxl.UUCP> Date: Mon, 31-Mar-86 13:41:06 EST Article-I.D.: whuxl.1075 Posted: Mon Mar 31 13:41:06 1986 Date-Received: Sat, 5-Apr-86 00:44:57 EST References: <515@ssc-bee.UUCP> <615@umcp-cs.UUCP> Distribution: net Organization: AT&T Bell Laboratories, Whippany Lines: 35 Chris Torek writes: > In article <515@ssc-bee.UUCP> bossert@ssc-bee.UUCP writes: > >Where the desired goal is disassociation of a process from its > >controlling tty, what are the differences between > > setpgrp() and ioctl(TIOCSPGRP) > > >? Which is preferable? Why? > > Neither. Use > > if ((t = open("/dev/tty", 0)) >= 0) { > (void) ioctl(t, TIOCNOTTY, 0); > (void) close(t); > } If your control tty is a modem that has been hung up, the open() hangs waiting for someone to call! Also, that only works on BSD systems. On System V, call setpgrp() (no arguments). This will disassociate the control tty, and create a new group with the calling process as the leader. The next open of a tty that isn't already associated with a group will become the leader's control tty. > Note that if you execute this call without fork()ing, then wait > for some event, the shell will never regain control of the terminal > (if the process was started without `&'). Again this is only csh under BSD. Under sh or on System V you can call setpgrp() without forking without any problems. -- Michael Baldwin (not the opinions of) AT&T Bell Laboratories {at&t}!whuxl!mike