It is indeed the session that has a controlling terminal
The Single UNIX Specification describes the relationship in terms of the controlling terminal being "associated with a session". As it goes on to specify, a controlling terminal has a 1:1 relationship with a session. There is "at most one controlling terminal" associated with a session, and "a controlling terminal is associated with exactly one session".
The FreeBSD Design and Implementation book approaches this slightly differently, but reaches the same place. It is not possible for processes that share the same session to have different controlling terminals, nor is it possible for a single terminal to be the controlling terminal of multiple sessions.
Internally in FreeBSD that is how the data structures actually work. The process structure has a pointer to the
pgrp structure representing the process group that the process belongs to, which in turn points to the
session structure representing the session that the process group belongs to, which in turn points to the
tty structure of the controlling terminal for the session.
Internally in Linux, things are slightly more complex. Each
task_struct has a set of pointers to
pid structures for its process group ID and session ID; and has another pointer to a per-process
signal_struct structure that in turn directly points to the
tty structure of the controlling terminal.
- George V. Neville-Neil, Marshall Kirk McKusick, and Robert N.M. Watson (2014-09-25). "Process Management". The Design and Implementation of the FreeBSD Operating System. Addison-Wesley Professional. ISBN 9780133761832.
- Donald Lewine (1991). "Terminal I/O". POSIX Programmers Guide. O'Reilly Media, Inc. ISBN 9780937175736.
- Daniel P. Bovet and Marco Cesati (2005). "Processes". Understanding the Linux Kernel: From I/O Ports to Process Management. 3rd edition. O'Reilly Media, Inc. ISBN 9780596554910.
- "Definitions". The Open Group Base Specifications. Issue 7. 2016. IEEE 1003.1:2008.
- "General Terminal Interface". The Open Group Base Specifications. Issue 7. 2016. IEEE 1003.1:2008.