C : poll 功能限制
当我使用 poll 函数并将数量设置为 1000 以上时,它根本不休眠。关于这可能是什么的任何想法。 opengroup 没有提到限制,而且我还没有耗尽我的内存空间。但是当我检查指针时,整数是负数。你知道这可能是什么吗?
When I use the poll function and set the quantity above 1000 it does not sleep at all. Any ideas of what this could be. opengroup says nothing about a limit and I am no where near exhausting my memory space. But when I check the pointer the integer is negative. Any ideas of what this could be?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的猜测是您的文件描述符限制设置为 1024。您可以通过在 bash (unix) 中运行
ulimit -n
来查看这一点。对于 Windows,请参阅 http://support.microsoft.com/kb/111855。如果您运行的是 Linux,则可以通过修改 /etc/limits.conf (或 /etc/security/limits.conf 或类似文件)来增加该限制,例如:请注意,更改限制后,您将必须注销并重新登录使其具有新的值。
My guess is that your limit for file descriptors is set to 1024. You can see this by running
ulimit -n
in bash (unix). For windows see http://support.microsoft.com/kb/111855. If you are running linux, you can increase that limit by modifying /etc/limits.conf (or /etc/security/limits.conf or similar) like:Note that after changing the limits you will have to log out and log back in for it to have the new values.
如果
poll()
返回负数,则应使用perror("poll");
来显示原因。如果原因是“无效参数”,则可能是由于这个原因(来自 Linux
poll()
手册页):顺便说一句,POSIX 规范也将其列为错误:
If
poll()
returns a negative number, you should useperror("poll");
to show the reason.If the reason is "Invalid Argument", it could be for this reason (from the Linux
poll()
man page):By the way, the POSIX spec lists this as an error too: