(In reply to Thomas Blume from comment #15) > return (tbsize = (int)rl.rlim_max); > > seems to be a bit excessive. > But I'm not sure how else to determine a good value. > Thorsten, would be changing this to the soft limit appropriate, e.g: > > return (tbsize = (int)rl.rlim_cur); > > ? Indeed that was my thinking too and it's actually how glibc implements getdtablesize(3). It looks like there might be a bug here therefore I would suggest to send a patch upstream that make the code use the soft limit. But that won't be sufficient unfortunately because PID1 initializes the rlimits of its child *after* calling initgroups(3). Therefore the soft limit will still be the one used by PID1 which is still equal to the hard limit. I'll send a patch to upstream to attempt to fix it.