main: improve RLIMIT_NOFILE handling (#5795)
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 26 Apr 2017 04:18:10 +0000 (06:18 +0200)
committerEvgeny Vereshchagin <evvers@ya.ru>
Wed, 26 Apr 2017 04:18:10 +0000 (07:18 +0300)
commit6385cb31ef443be3e0d6da5ea62a267a49174688
tree9507904f4b870e4ae2d355f616ca4a2ceb640892
parent1f0f4f3bfd05fd416e3e2dea10ad225b276a6ef7
main: improve RLIMIT_NOFILE handling (#5795)

This has systemd look at /proc/sys/fs/nr_open to find the current maximum of
open files compiled into the kernel and tries to set the RLIMIT_NOFILE max to
it. This has the advantage the value chosen as limit is less arbitrary and also
improves the behavior of systemd in containers that have an rlimit set: When
systemd currently starts in a container that has RLIMIT_NOFILE set to e.g.
100000 systemd will lower it to 65536. With this patch systemd will try to set
the nofile limit to the allowed kernel maximum. If this fails, it will compute
the minimum of the current set value (the limit that is set on the container)
and the maximum value as soft limit and the currently set maximum value as the
maximum value. This way it retains the limit set on the container.
src/core/main.c