> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/4.3-bsd-unix-cao-zuo-xi-tong-she-ji-yu-shi-xian/di-yi-bu-fen-gai-lan/2.9.-zhong-duan.md).

# 2.9 终端

终端支持标准的系统 I/O 操作，也支持一组终端专用的操作，用来控制输入字符的编辑和输出延迟。最低层是控制硬件终端端口的终端设备驱动。终端输入按底层通信特性（如波特率）和一组软件可控参数（如奇偶校验）处理。

在终端设备驱动之上是行规程（line discipline），提供不同程度的字符处理。端口用于交互登录时，通常采用默认行规程。默认行规程有三种模式：原始（raw）、cbreak 和规范（cooked）。原始模式下，输入不加解释、立即传给读进程。cbreak 模式下，终端处理程序只解释那些引发信号或输出流控制的输入字符；其余字符同原始模式一样直接传给进程。规范模式下，输入经过处理提供标准的面向行的编辑功能，并按行呈现给进程。

输出方面，终端处理程序提供一些简单的格式化服务，包括：

* 把换行字符转换为“回车-换行”两字符序列
* 在某些标准控制字符之后插入延迟
* 展开制表符
* 为仅大写终端提供转换
* 把回显的非图形 ASCII 字符显示为形如 “^X” 的两字符序列（即 ASCII 脱字符后跟一个与该控制字符相关的可打印 ASCII 字符）

进程可以通过控制请求逐一停用这些格式化服务。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://book.bsdcn.org/4.3-bsd-unix-cao-zuo-xi-tong-she-ji-yu-shi-xian/di-yi-bu-fen-gai-lan/2.9.-zhong-duan.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
