HP-UX Reference (11i v3 07/02) - 7 Device (Special) Files, 9 General Information, Index (vol 10)
t
termio(7) termio(7)
NAME
termio, termios - general terminal interface
DESCRIPTION
All HP-UX asynchronous communications ports use the same general interface, regardless of what
hardware is involved. Network connections such as
rlogin (see rlogin(1) use the pseudo-terminal inter-
face (see pty(7).
This discussion centers around the common features of this interface.
Opening a Terminal File
When a terminal file is opened, it normally causes the process to wait until a connection is established. In
practice, users’ programs seldom open these files; they are opened by special programs such as
getty (see
getty(1M)) and become a user’s standard input, standard output, and standard error files.
If both the
O_NDELAY and O_NONBLOCK flags (see open(2)) are clear, an open blocks until the type of
modem connection requested (see modem(7)) is completed. If either the
O_NDELAY or O_NONBLOCK
flag is set, an open succeeds and return immediately without waiting for the requested modem connection
to complete. The
CLOCAL flag (see Control Modes) can also affect open(2).
Process Groups
A terminal can have a foreground process group associated with it. This foreground process group plays a
special role in handling signal-generating input characters.
Command interpreter processes can allocate the terminal to different jobs (process groups) by placing
related processes in a single process group and associating this process group with the terminal. A
terminal’s foreground process group can be set or examined by a process, assuming that the permission
requirements are met (see tcsetpgrp(3C) or tcgetpgrp(3C)). The terminal interface aids in this allocation by
restricting access to the terminal by processes that are not in the foreground process group.
A process group is considered orphaned when the parent of every member of the process group is either
itself a member of the process group or is not a member of the group’s session (see Sessions).
Sessions
A process that creates a session (see setsid(2) or setpgrp(2)) becomes a session leader. Every process group
belongs to exactly one session. A process is considered to be a member of the session of which its process
group is a member. A newly created process joins the session of its parent. A process can change its ses-
sion membership (see setpgid(2) or setpgrp(2)). Usually a session comprises all the processes (including
children) created as a result of a single login.
The Controlling Terminal
A terminal can belong to a process as its controlling terminal. Each process of a session that has a control-
ling terminal has the same controlling terminal. A terminal can be the controlling terminal for at most one
session. The controlling terminal for a session is allocated by the session leader. If a session leader has no
controlling terminal and opens a terminal device file that is not already associated with a session without
using the
O_NOCTTY option (see open(2), the terminal becomes the controlling terminal of the session and
the controlling terminal’s foreground process group is set to the process group of the session leader. While
a controlling terminal is associated with a session, the session leader is said to be the controlling process of
the controlling terminal.
The controlling terminal is inherited by a child process during a fork() (see fork(2)). A process relinqu-
ishes its controlling terminal if it creates a new session with setsid() or setpgrp() (see setsid(2)
and setpgrp(2)), or when all file descriptors associated with the controlling terminal have been closed.
When the controlling process terminates, the controlling terminal is disassociated from the current session,
allowing it to be acquired by a new session leader. A SIGHUP signal is sent to all processes in the fore-
ground process group of the controlling terminal. Subsequent access to the terminal by other processes in
the earlier session can be denied (see Terminal Access Control) with attempts to access the terminal treated
as if a modem disconnect had been sensed.
Terminal Access Control
Read operations are allowed (see Input Processing and Reading Data) from processes in the foreground
process group of their controlling terminal. If a process is not in the foreground process group of its con-
trolling terminal, the process and all member’s of its process group are considered to be in a background
process group of this controlling terminal. All attempts by a process in a background process group to read
HP-UX 11i Version 3: February 2007 − 1 − Hewlett-Packard Company 209