星巡研究院

渗透视角下的C语言

``` #include <poll.h> struct pollfd pfds[2]; pfds[0].fd = client_fd; pfds[0].events = POLLIN; /* 关注客户端可读 */ pfds[1].fd = target_fd; pfds[1].events = POLLIN; int n = poll(pfds, 2, 1000); /* rax=7,等待最多1秒,返回就绪项数 */ if (pfds[0].revents & POLLIN) { /* 内核回填revents,判断是否可读 */ /* 处理client_fd */ } if (pfds[1].revents & POLLHUP) { /* 判断对端关闭 */ /* 清理target_fd */ } ``` 链路:`poll()` → glibc 置 `rax=7`,`rdi=fds` 数组指针、`rsi=nfds`、`rdx=timeout` → 陷入后内核遍历监听项、把就绪结果写回每项 `revents` → 返回就绪总数。超
这是进阶内容

升级理论包获取本册全部章节,从机器本质系统入门