mirror of
https://github.com/NohamR/knowledge-kit.git
synced 2026-05-24 20:00:37 +00:00
feat: Socket层SIGPIPE信号Crash
This commit is contained in:
@@ -39,6 +39,15 @@ Mach 异常都在 host 层被 `ux_exception` 转换为相应的 unix 信号,
|
||||
int value = 1;
|
||||
setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, &value, sizeof(value));
|
||||
```
|
||||
|
||||
|
||||
`SO_NOSIGPIPE` 是一个宏定义,跳过去看一下实现
|
||||
|
||||
```c++
|
||||
#define SO_NOSIGPIPE 0x1022 /* APPLE: No SIGPIPE on EPIPE */
|
||||
```
|
||||
|
||||
什么意思呢?没有 SIGPIPE 信号在 EPIPE。那啥是 `EPIPE`。
|
||||
|
||||
其中:**EPIPE** 是 socket send 函数可能返回的错误码之一。如果发送数据的话会在 Client 端触发 RST(指Client端的 FIN_WAIT_2 状态超时后连接已经销毁的情况),导致send操作返回 `EPIPE`(errno 32)错误,并触发 `SIGPIPE` 信号(默认行为是 **Terminate**)。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user