Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!mcvax!enea!zyx!aj From: aj@zyx.UUCP (Arndt Jonasson) Newsgroups: comp.unix.questions Subject: What is the name of /dev/tty? Message-ID: <1418@zyx.UUCP> Date: Mon, 12-Oct-87 12:54:26 EDT Article-I.D.: zyx.1418 Posted: Mon Oct 12 12:54:26 1987 Date-Received: Sun, 18-Oct-87 08:48:00 EDT Reply-To: aj@zyx.SE (Arndt Jonasson) Organization: ZYX Sweden AB, Stockholm Lines: 26 Is there any way in Unix (either BSD or SYS5) to obtain the true name of the process's controlling terminal? In other words, if my program opens /dev/tty, how can it find out which real terminal this corresponds to? The real name may be something like /dev/ttyp2. Examples (imagine 'prog' being run on /dev/ttyp2): prog >foo Here isatty(3) says that stdout is not a tty, so this case is easy. prog Here /dev/tty and stdout are 'the same'. prog >/dev/ttyp6 Here they are not. The reason why it would be interesting to know this is that I want my program to know whether its standard output and its controlling terminal are the same, in the sense that output to the two streams will mix on the same window/screen. Error messages will use /dev/tty only if it is not the same as stdout, to avoid mixing of output from different write operations on the screen. -- Arndt Jonasson, ZYX Sweden AB, Styrmansgatan 6, 114 54 Stockholm, Sweden email address: !mcvax!enea!!zyx!aj = aj@zyx.SE