]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: raise RLIMIT_NOFILE as high as we can
authorLennart Poettering <lennart@poettering.net>
Tue, 26 Sep 2023 07:52:05 +0000 (09:52 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 26 Sep 2023 11:01:02 +0000 (13:01 +0200)
We might need a lot of fds on large systems, hence raise RLIMIT_NOFILE
to what the service manager allows us, which is quite a lot these days.

udev already sets FORK_RLIMIT_NOFILE_SAFE when forking of chilren, thus
ensuring that forked off processes get their RLIMIT_NOFILE soft limit
reset to 1K for compat with crappy old select().

Replaces: #29298
Fixes: #28583
src/udev/udevd.c

index 257336aec6fcdb8e81c8a31eebe7321b1d42040b..2ed4282253ec5cf0475036e35859ad3ec2394615 100644 (file)
@@ -18,6 +18,7 @@
 #include "pretty-print.h"
 #include "proc-cmdline.h"
 #include "process-util.h"
+#include "rlimit-util.h"
 #include "selinux-util.h"
 #include "signal-util.h"
 #include "syslog-util.h"
@@ -365,6 +366,9 @@ int run_udevd(int argc, char *argv[]) {
         if (r < 0)
                 return r;
 
+        /* Make sure we can have plenty fds (for example for pidfds) */
+        (void) rlimit_nofile_bump(-1);
+
         r = RET_NERRNO(mkdir("/run/udev", 0755));
         if (r < 0 && r != -EEXIST)
                 return log_error_errno(r, "Failed to create /run/udev: %m");