Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uunet!zephyr.ens.tek.com!tektronix!percy!percival.rain.com!nerd From: nerd@percival.rain.com (Michael Galassi) Newsgroups: comp.unix.sysv386 Subject: Re: TIOCNOTTY under SCO System V/386 Keywords: TIOCNOTTY Message-ID: <1991Jun22.011114.14327@percy.rain.com> Date: 22 Jun 91 01:11:14 GMT References: <54@jeanluc.UUCP> Sender: news@percy.rain.com (news maintainer) Organization: Percy's UNIX, Portland, OR. Lines: 49 Nntp-Posting-Host: percival.rain.com stockett@jeanluc.UUCP (Jeffrey M. Stockett) writes: >I'm trying to port over some code from a BSD machine to SCO System V/386, >and I have run into a problem with the following lines: > if ((s = open("/dev/tty", O_RDWR)) >= 0) { > ioctl(s, TIOCNOTTY, 0); > close(s); > } Stab in the dark, looks like the debug code in rlogind. If this is the case, #undef DEBUG, the TIOCNOTTY is not a good thing to have occur to the controlling terminal of an interactive session. If I'm wrong, here is the code to replace the above fragment: (void) setpgrp(); This will dissociate you from the controlling terminal and will make the next terminal you open the controlling terminal. There are other side effects to this call, read the man page and know how these may affect you. FYI, this is the relevant section from the BSD man page (tty(4)). A process can remove the association it has with its con- trolling terminal by opening the file /dev/tty and issuing an ioctl(f, TIOCNOTTY, 0); And, here is the relevant section from the Xenix man page (setpgrp(S)) There are many ramifications to be considered before invoking setpgrp. When a process is made a process group leader with setpgrp, the terminal that controlled the process that issued the setpgrp statement is lost as the controlling terminal for the new process group. The new process group takes as its controlling terminal the next terminal it opens that is not already open. I assume that the functionality of setpgrp is identical in sco xenix and sco unix. Cheers, -m -- Michael Galassi | nerd@percival.rain.com MS-DOS: The ultimate PC virus. | ...!tektronix!percy!nerd