【发布时间】:2021-06-15 17:34:13
【问题描述】:
我正在尝试编写一个让我打破 epoll_wait() 的函数。
我有
void SocketSystem::epollBreakWait(int epoll)
{
if (epoll == ERROR_CODE)
return;
int selfpipe[PIPE_PAIR];
if (pipe(selfpipe) < 0)
std::cout << "Error on self pipe." << std::endl;
if (::epoll_ctl(epoll, EPOLL_CTL_ADD, selfpipe[0], NULL) == ERROR_CODE)
std::cout << "Error breaking epoll." << std::endl;
int temp = 0;
::write(selfpipe[1], &temp, sizeof(temp));
}
但是当我运行它时,我得到错误 (-1) 和 errno = Bad address。 有什么想法吗?
【问题讨论】:
标签: epoll