c++ - select(NULL, NULL, NULL, &timeout) 只是等待给定的时间吗?

标签 c++ linux

我在给定的代码中看到了以下行:

select(0, (fd_set *) NULL, (fd_set *) NULL, (fd_set *) NULL, &timeout);

http://linux.die.net/man/2/select

Each of the three file descriptor sets may be specified as NULL if no file descriptors are to be watched for the corresponding class of events.

所以我可以看到将NULL传递给它是有效的。那样的话只能导致做主动等待。

这是正确的吗?我有点不确定..

最佳答案

Some code calls select() with all three sets empty, nfds zero, and a non-NULL timeout as a fairly portable way to sleep with subsecond precision.

取自here .

关于c++ - select(NULL, NULL, NULL, &timeout) 只是等待给定的时间吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27297184/

相关文章:

c++ - 如何从类外部设置成员变量并在 C++ 中使用类内部的变量?

c++ - 如何使用 C++ 有效地将排序与 vector 合并

c++ - boost::multiprecision::gmp_float::operator =?中的神秘stackoverflow异常?

linux - 如何从 Go 配置文件中获取函数分解

linux - Icinga 2 安装

c++ - 如何比较/排序包含自定义 typedef 的列表容器的元素?

c++ - 为什么模板只能在头文件中实现?

linux - 如何在linux中使用cp命令将文件x中的数据追加到文件y?

linux - 提取 zip 文件,然后使用不同的文件名将其 cd 进去

python - Windows Python 代码不适用于 Linux Debian