buildFdSets: file descriptor out of range

Kazu Yamamoto ( 山本和彦 ) kazu at
Wed Jul 15 00:42:43 EDT 2009

> I believe the runtime uses select(), which has a hard limit (enforced
> by the kernel) that the maximum file descriptor id be 1023.  (select()
> uses bitmasks and there is a limit on the size of a bitmask; see

I understand. Thank you.

> Reduce this to 1024, otherwise the runtime will eventually find itself
> dealing with file descriptors beyond the select() limit mentioned
> above.  Someone with more knowledge of the Haskell runtime will have
> to advise as to possible ways around it if you really need more than
> 1024 file descriptors.

I used to execute my server with the limit of 1024 since this is the
default limit of my machine. At that time, I suffered from the
following errors:

	rpf: user error (Cannot create OS thread.)
	rpf: accept: resource exhausted (Too many open files)

So, I pushed the limit to 65536.

I don't believe my server receives 1024 connections at once. So, I guess
file descriptors leak.

Does anyone know what happens when a TCP connection is reset by the
peer and its handle disappears. Does the file descriptor bound to the
handle leak?


More information about the Glasgow-haskell-users mailing list