Why does a process have to have a tty open for stty to work (SysV)

Doug Gwyn gwyn at smoke.brl.mil
Fri Mar 1 04:02:03 AEST 1991


In article <JIM.91Feb27134014 at baird.cs.strath.ac.uk> jim at cs.strath.ac.uk (Jim Reid) writes:
>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 disagree with this summary of the history.  I seem to recall that
PWB "stty", certainly UNIX System III "stty", shared this aspect of
the current "stty" behavior.

>I suspect the reasoning was to allow the text output of an stty
>command to be redirected to a file or down a pipe.

Exactly.  This is quite useful at times.

>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.

The use of TCGETA amounts to a "read", not a "write".  If you change
the terminal handler settings via TCSETAW, then that amounts to a
"write".  "stty" has both uses.



More information about the Comp.unix.questions mailing list