来自民意调查手册页:
The bits returned in revents can include any of those specified in events, or one of the values POLLERR, POLLHUP, or POLLNVAL
返回值:
On success, a positive number is returned; this is the number of structures which have nonzero revents fields (in other words, those descriptors with events or errors reported). A value of 0 indicates that the call timed out and no file descriptors were ready. On error, -1 is returned, and errno is set appropriately.
如果 poll 在 revents 中设置了 POLLERR、POLLHUP 或 POLLNVAL 之一,这是否意味着 poll 函数将返回 -1?如果不是,poll什么时候会返回-1?
我的猜测是否定的,因为返回值解释中的第一句话是返回是具有非零 revents 字段的结构的数量。因此,如果设置了 POLLERR,则至少有 1 个具有非零 revents 的结构。
最佳答案
If poll sets one of POLLERR, POLLHUP, or POLLNVAL in revents, does this mean that the poll function will return -1?
没有。如果 poll()
设置任何 revents
值,那么它将返回 >0
来表明这一点。然后,您必须检查各个项目以查看哪些项目分配了 revents
值。
If not, when will poll return -1?
poll()
仅当 poll()
本身失败时返回 -1
,而不是在任何被轮询的项目失败时返回。
关于c - 如果设置了任何 POLLERR、POLLHUP 或 POLLNVAL revents,poll 是否会返回 -1?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22890021/