0

select(2) システム コールは、Stevens、Fenner、および Rudoff による Unix Network Programming (2003) の第 6.3 章で次のように定義されています。

#include <sys/select.h>
#include <sys/time.h>
int select(int maxfdp1, fd_set *readset, fd_set *writeset,
        fd_set *exceptset, const struct timeval *timeout);

しかし、FreeBSD、OpenBSD、NetBSD、Linux、さらには POSIX[1] 標準などの最新の Unix では、システム コールがそのように定義されていません。ただし、「POSIXはconst修飾子を指定する」と本に記載されています。本の間違いですか?それとも、歴史的な理由によるものですか?ただし、すべてのシステムで pselect(2) が一定のタイムアウト パラメータを持つように定義されています。

http://pubs.opengroup.org/onlinepubs/009695399/functions/pselect.html

本の正誤表ページには、これがエラーとして記載されていません。

http://www.unixnetworkprogramming.com/errata.html

4

1 に答える 1

0

POSIX では、インターフェイスを次のように定義していますselect()

int select(int nfds, fd_set *restrict readfds,
       fd_set *restrict writefds, fd_set *restrict errorfds,
       struct timeval *restrict timeout);

select() 関数は、次の点を除いて pselect() 関数と同等です。

  • ...
  • 正常に完了すると、select() 関数は、タイムアウト引数が指すオブジェクトを変更する場合があります。

pselect関数はconst struct timespec * restrict timeout引数を取ります (POSIX 定義の同じページ) 。

constで引用されている修飾子は間違いです。

于 2015-04-10T00:44:24.770 に答える