Skip to Content
LINUX系統程式設計 第二版
book

LINUX系統程式設計 第二版

by Robert Love
December 2013
Intermediate to advanced
496 pages
8h 57m
Chinese
GoTop Information, Inc.
Content preview from LINUX系統程式設計 第二版
110
|
第四章
event.data.fd = fd; /* 稍後把 fd 傳回給我們 */
event.events = EPOLLIN;
ret = epoll_ctl (epfd, EPOLL_CTL_MOD, fd, &event);
if (ret)
perror ("epoll_ctl");
反過來說,欲從「epoll 實例」
epfd
中移除特定檔案(相應於
fd
)上一個既存的事件檢
視器,可以這麼做:
struct epoll_event event;
int ret;
ret = epoll_ctl (epfd, EPOLL_CTL_DEL, fd, &event);
if (ret)
perror ("epoll_ctl");
注意,當
op
的值為
EPOLL_CTL_DEL
時,
event
參數可以是
NULL
,因為沒有提供事件遮
罩(event mask)。然而,核心版本在 2.6.9 之前,會錯誤地檢查此參數是否為「非
NULL」值。若要移植到這些版本較舊的核心,你應該傳進一個有效的「非 NULL」指
標;它將不會被觸動。核心版本 2.6.9 已修正此瑕疵。
epoll 等待事件
系統呼叫
epoll_wait()
用於等待「與特定 epoll 實例相對應之檔案描述器」上的事件:
#include <sys/epoll.h>
int epoll_wait (int epfd,
struct epoll_event *events,
int maxevents,
int timeout);
叫用
epoll_wait() ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

優雅的SciPy|Python科學研究的美學

優雅的SciPy|Python科學研究的美學

Juan Nunez-Iglesias, Stéfan van der Walt, Harriet Dashnow
C++语言导学(原书第2版)

C++语言导学(原书第2版)

本贾尼 斯特劳斯特鲁普

Publisher Resources

ISBN: 9789862769812