38.6 The Controlling TerminalIn article 38.5 , we pointed out that the ps command needs special options ( -x for BSD and -e for System V) to list processes without a controlling terminal. But just what is a controlling terminal? Just what it sounds like: the terminal from which the process was started. In the ps listing, this is usually given as a tty , or terminal id. That ps entry usually corresponds to a serial port, or a pty ( 41.8 ) . A pty or "pseudo-terminal" is a construct that makes a window or network login ( 1.33 ) look to the operating system just like a terminal.
In the
ps
listing, a tty might appear as How does a process "lose" its controlling terminal? Easy. Some processes, such as system "daemons" ( 1.14 ) never had one - they were started by system scripts that weren't started from any terminal, or they disconnected themselves from their controlling terminals. But it's also possible that you started a process running in the background, logged out, and logged back later or on another terminal to find it still running without a controlling terminal. The tty command can be used to report which "terminal" you're currently connected to. For example:
%
Running
tty
without a controlling terminal gives the
message - |
|