home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 38.5 The ps Command Chapter 38
Starting, Stopping, and Killing Processes
Next: 38.7 Why ps Prints Some Commands in Parentheses

38.6 The Controlling Terminal

In 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 t1 for /dev/tty1 , p3 for /dev/ttyp3 , or as some other designation, such as co for /dev/console , the full screen display of a workstation before any window system is started. Processes without a controlling terminal show a question mark (? ).

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:

% tty


Running tty without a controlling terminal gives the message not a tty .


Previous: 38.5 The ps Command UNIX Power Tools Next: 38.7 Why ps Prints Some Commands in Parentheses
38.5 The ps Command Book Index 38.7 Why ps Prints Some Commands in Parentheses

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System