Why does a process have to have a tty open for stty to work (SysV)
Jim Reid
jim at cs.strath.ac.uk
Thu Feb 28 00:40:14 AEST 1991
In article <8845 at suns302.crosfield.co.uk> ir at 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
More information about the Comp.unix.questions
mailing list