UNIX(编程-高级IO):04---IO复用(pselect函数)

pselect函数

#include <sys/select.h>
int pselect
(
int maxfdp1, 
fd_set *restrict readfds,
fd_set *restrict writefds, fd_set *restrict exceptfds,
const struct timespec *restrict tsptr,
const sigset_t *restrict sigmask
);

pselect的用法、返回值都与select相同

但是后面两个参数与select不同:

  • ①参数4使用timespec结构。该结构以秒和纳秒表示超时值,而非秒和微秒。如果平台支持,可以使用此结构提供更精准的超时时间。并且该参数为const类型,保证了pselect不会改变该值
  • ②参数5可使用信号屏蔽字:若sigmask为NULL,那么在与信号有关的方面,pselect和select使用相同。否则,sigmask指向一信号屏蔽字,在调用pselect时,以原子操作的方式安装该信号屏蔽字。在返回时,恢复以前的信号屏蔽字

猜你喜欢

转载自blog.csdn.net/qq_41453285/article/details/89340778