Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

The controlling terminal

&pagelevel(5)&pagelevel

A terminal may belong to a process as its controlling terminal. Every process of a session that has a controlling terminal has the same controlling terminal. A terminal may be the controlling terminal for at most one session. The first open terminal device file is reserved as the controlling terminal for a session by the session leader. If a session leader has no controlling terminal and opens a terminal device file (without the O_NOCTTY bit set) that is not already associated with a session (see open()), the terminal can become the controlling terminal of the session leader. If a process which is not a session leader opens a terminal file, or if the O_NOCTTY option is used when calling open(), then that terminal does not become the controlling terminal of the process. When a controlling terminal becomes associated with a session, its foreground process group is set to the process group of the session leader.

The controlling terminal is inherited by a child process by means of a fork call. A process relinquishes its controlling terminal when it creates a new session with the setsid() function, or when all file descriptors associated with the controlling terminal have been closed..

When a controlling process terminates, the controlling terminal is disassociated from the current session, allowing it to be acquired by a new session leader. Subsequent access to the terminal by other processes in the earlier session may be denied, with attempts to access the terminal treated as if a modem disconnect had been sensed.