开发者

C : poll function limit

开发者 https://www.devze.com 2023-02-23 15:18 出处:网络
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

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. An开发者_Go百科y ideas of what this could be?


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:

*               soft    nofile  10240
*               hard    nofile  10240

Note that after changing the limits you will have to log out and log back in for it to have the new values.


If poll() returns a negative number, you should use perror("poll"); to show the reason.

If the reason is "Invalid Argument", it could be for this reason (from the Linux poll() man page):

EINVAL

The nfds value exceeds the RLIMIT_NOFILE value.

By the way, the POSIX spec lists this as an error too:

The poll() function shall fail if: ... [EINVAL] The nfds argument is greater than {OPEN_MAX}

0

精彩评论

暂无评论...
验证码 换一张
取 消