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的有一個發明。spa

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

這兩個結構的區別在於第二個成員:新結構的該成員tv_nsec指定納秒數,而舊結構的該成員tv_usec指定微秒數。指針

(2)pselect函數增長了第六個參數:一個指向信號掩碼的指針。code

image

相關文章
相關標籤/搜索