# 多进程共用数据库连接问题

我们知道，每次fork操作系统都会复制进程的所有信息产生一个子进程（部分写时复制），其中就包括socket链接资源符。每个进程在PCB（Process Control Block）中都保存着一份文件描述符表，文件描述符就是这个表的索引，每个表项都有一个指向已打开文件的指针，现在我们明确一下：已打开的文件在内核中用file结构体表示，文件描述符表中的指针指向file结构体。实际上包括文件描述符，socket等资源符号，操作系统并没有真的复制，而是在父子进程之间复制了资源符的指针。


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bing.gitbook.io/phper/base/networks/notes/duo-jin-cheng-gong-yong-shu-ju-ku-lian-jie-wen-ti.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
