0
We are told that a tty can control at most one session and furthermore that ttys can be controlled not to allow background process groups within its controlled session to write or read from it, the former being controlled by the TOSTOP
option.
However, what is the position on other sessions writing to a tty? Can it be controlled in some way? Assume tty1
and tty2
, both with shells. I was surprised that the following command on shell2
on tty2
...
ls > /dev/tty1
...actually produced the output from ls
on tty1
, no matter what the TOSTOP
option was set to in tty1
. Since shell2
is altogether part of another session, I figured that might be it, because the TOSTOP
option indeed does what it's supposed to when attempting to write from a background process group. Could someone enlighten me what's going on?
The known relationship being that they have the same session id that is? So it would then follow that the tty driver checks this, and if they're not in the same session, it would allow a write if the user permissions allow it? – fast-reflexes – 2015-05-15T10:45:28.357
That's my impression, yes - perhaps known to the tty driver as having the same controlling terminal. – Thomas Dickey – 2015-05-15T10:56:09.690
Well, seems about correct, I tried writing to a tty owned by root instead and then it wouldn't allow me, thanks! – fast-reflexes – 2015-05-15T11:21:35.117