UNIX网络编程读书笔记:pselect函数

红心函数原型

pselect函数是由POSIX发明的,其原型如下:

#include <sys/select.h>
#include <signal.h>
#include <time.h>
int pselect (int maxfdpl, fd_set *readset, fd_set *writeset, 
    fd_set *exceptset, const struct timespec *timeout,
    const sigset_t *sigmask);
返回值:就绪描述字的个数,0——超时,-1——出错

红心pselect相对于select的两个变化

(1)pselect使用timespec结构,而不使用timeval结构。timespec结构是POSIX的有一个发明。

struct timespec {
    time_t    tv_sec;     /* seconds */
    long      tv_nsec;    /* nanoseconds */
};

这两个结构的区别在于第二个成员:新结构的该成员tv_nsec指定纳秒数,而旧结构的该成员tv_usec指定微秒数。

(2)pselect函数增加了第六个参数:一个指向信号掩码的指针。

image

原文地址:https://www.cnblogs.com/nufangrensheng/p/3590084.html