Sessions and Process Groups have some other features:
- A session can have a control terminal (controlling terminal). This is usually logged on to itTerminal Device (in the case of terminal login) or Pseudo Terminal Device (in the case of network login)).
- The first process of a session established to connect to the control terminal is called the controlling process).
- Several process groups in a session can be dividedA foreground process group) AndOne or more background process groups).
- If a session has a control terminal, it has a foreground process group, and other process groups in the session are background process groups..
- Whenever you type the terminal's interrupt key (usually DELETE or Ctrl + C ),All processes sent from the interrupt signal to the foreground Process Group.
- Whenever you type the terminal's return key (usually Ctrl + \),The exit signal is sent to all processes in the foreground process group..
- If the terminal interface detects that the modem (or Network) is disconnectedSend the hanging signal to the control process (the first process of the session)).
These features are shown in Figure 9-7.
Sometimes, the program must be switched with the control terminal regardless of whether the standard input or standard output is redirected.To ensure that the program can read and write the control terminal, open the file/dev/tty. In the kernel, this special file is the definition of the control terminal.Naturally, if the program has no control terminal, opening the device will fail.
This blog is excerpted from advanced programming for UNIX environments (version 2) and used only for personal learning records. For more information about this book, see:Http://www.apuebook.com/.