Arpit
Arpit

Reputation: 4407

Poll is causing crash

I am getting a crash with following values :-

Poll is the system call in use giving "errno" as 24 (EMFILE) and struct pollfd has values "fd = 1022, events = 1, revents = 32"

Here we are woking on "fd = 1022" then why it is showing "errno" as 24 (EMFILE /Too many files open/)

I have multiple threads which works in an Infinite loop.

Upvotes: 0

Views: 863

Answers (1)

bstpierre
bstpierre

Reputation: 31256

On my machine, ulimit -a shows 1024 for max open files. 1022 is really close to that limit.

Do you have code that is trying to open a file and is failing? It is probably some other system call that is setting errno to EMFILE.

Make sure you're handling return values from code that opens fds.

Make sure you're not leaking file descriptors somewhere.

If this code runs with appropriate privileges, you can try increasing the max open file limit with ulimit -n or setrlimit().

Upvotes: 2

Related Questions