Try to increase file descriptor rlimit if necessary

As the default can be too low, especially on OSX.
Merge pull request #2568 from sipa/rlimit

Try to increase file descriptor rlimit if necessary