0

我有一个使用 IPv4 的服务器程序。服务器必须参加来自客户端的多次调用,因此它每次接受客户端套接字连接时都会创建一个子进程来处理客户端。

子进程应从客户端读取,然后写入客户端套接字。如果它收到一个 SIGPIPE(来自一个在写入之前关闭的坏客户端),它应该在孩子的工作完成时终止。我是明确声明一个信号处理程序还是 SIGPIPE 默认终止它?我是初学者,所以请接受我的无知。

4

1 回答 1

0

来自man 7 signal

The entries in the "Action" column of the table below specify the default
disposition for each signal, as follows:

    Term   Default action is to terminate the process.
    [...]

然后,稍后在表格中:

Signal      Standard   Action   Comment
────────────────────────────────────────────────────────────────────────
[...]
SIGPIPE      P1990      Term    Broken pipe: write to pipe with no
                                readers; see pipe(7)

所以你不需要做任何事情,默认的信号处理程序会终止进程。

于 2021-08-11T22:47:41.273 回答