> 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-san-bu-fen-io-xi-tong/9.5.-jin-cheng-zu-yu-zhong-duan-kong-zhi.md).

# 9.5 进程组与终端控制

第 4 章描述的进程控制（作业控制）设施依靠终端 I/O 系统来控制对终端的访问。每个作业（一组受统一控制的进程）以一个进程组号标识；每个终端结构也含一个进程组号。终端初次打开时，shell 和终端被指派到一个进程组（shell 的 PID）。在终端上键入字符产生的信号，发给终端当前进程组中的全部进程；其中一些信号使进程组停止。shell 把每个作业的进程组号设为组内某一成员的 PID；每次把新作业放到前台，shell 就把终端进程组设为新进程组的组号。于是，终端进程组是当前控制终端的进程组——即运行在前台（foreground）的进程组——的标识；其他进程组在后台（background）运行。后台进程组中的进程试图从终端读时，其进程组会收到又一个信号而被停止。后台进程试图做终端输出时，也可以选择同样被停止。每个进程持有指向其控制终端（若有）的指针；上述输入输出操作的控制规则只适用于对控制终端的操作。

没有作业控制的早期系统对进程组的用法不同；4.3BSD 中使用不支持作业控制的登录 shell 时也会出现类似行为。shell 和终端起初被指派到同一进程组；这样的 shell 启动的新进程留在同一组里。因此，不用作业控制时，一个进程组标识着从同一登录 shell 发起的全部进程。


---

# 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-san-bu-fen-io-xi-tong/9.5.-jin-cheng-zu-yu-zhong-duan-kong-zhi.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.
