Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!strath-cs!baird!jim From: jim@cs.strath.ac.uk (Jim Reid) Newsgroups: comp.unix.questions Subject: Re: Why does a process have to have a tty open for stty to work (SysV) Message-ID: Date: 27 Feb 91 13:40:14 GMT References: <8845@suns302.crosfield.co.uk> Sender: jim@cs.strath.ac.uk Organization: Computer Science Dept., Strathclyde Univ., Glasgow, Scotland. Lines: 31 In-reply-to: ir@crosfield.co.uk's message of 27 Feb 91 11:11:26 GMT In article <8845@suns302.crosfield.co.uk> ir@crosfield.co.uk (ian reid) writes: Of course another interesting thing is stty (for another terminal - JR) works on the standard input for SysV systems, but on the standard output for BSD systems. So why does another process have to have the tty device open for the changes to work, and why the difference described in the previous paragraph between different stty implementations. The difference in implementations is System V's doing. The BSD stty command works in the same way that its predecessors like V7 worked. When AT&T cleaned up their tty driver, they changed the behaviour of stty. I suspect the reasoning was to allow the text output of an stty command to be redirected to a file or down a pipe. IMHO, this is wrong since intuitively stty `writes' an ioctl to the terminal, and it's not good practice to write on the standard input. Of course, other people will take the opposite view. As for the device open interaction with stty is concerned, this is a side effect of the tty driver. In most implementations, the device driver explicitly assigns default tty settings when the device gets opened, unless the tty is already open. So if the tty wasn't open, the driver will apply these defaults when stty comes along, opens the device and then issues a get-tty-settings ioctl. If the tty was already open, the driver knows this fact and therefore does not apply the default settings. Needless to say the default settings are far from useful - typically 300 baud, raw mode with @ and # for delete and line kill. Jim