pselect.c
来自「《unix网络编程第二卷》中的源代码」· C语言 代码 · 共 32 行
C
32 行
/* * This is *not* a complete implementation of the Posix.1g pselect() * function. For atomicity this must be implemented within the kernel, * with the sigprocmask/select/sigprocmask performed as a single atomic * operation. * This is just a quick hack to allow simple programs using it to compile. * Using such programs with this hack will probably lead to race conditions. *//* include pselect */#include "unp.h"intpselect(int nfds, fd_set *rset, fd_set *wset, fd_set *xset, const struct timespec *ts, const sigset_t *sigmask){ int n; struct timeval tv; sigset_t savemask; if (ts != NULL) { tv.tv_sec = ts->tv_sec; tv.tv_usec = ts->tv_nsec / 1000; /* nanosec -> microsec */ } sigprocmask(SIG_SETMASK, sigmask, &savemask); /* caller's mask */ n = select(nfds, rset, wset, xset, (ts == NULL) ? NULL : &tv); sigprocmask(SIG_SETMASK, &savemask, NULL); /* restore mask */ return(n);}/* end pselect */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?