aboutsummaryrefslogtreecommitdiff
path: root/os-posix.c
diff options
context:
space:
mode:
authorTrent Huber <trentmhuber@gmail.com>2024-06-14 17:06:38 -0400
committerMichael Tokarev <mjt@tls.msk.ru>2024-06-30 19:51:44 +0300
commitde448e0f26e710e9d2b7fc91393c40ac24b75847 (patch)
treef6fc5e276e7a0d246614eb9eee79b8466bda377f /os-posix.c
parent737308fe2be4cf653c3fe9e1358b6a08f673a5d1 (diff)
os-posix: Expand setrlimit() syscall compatibility
Darwin uses a subtly different version of the setrlimit() syscall as described in the COMPATIBILITY section of the macOS man page. The value of the rlim_cur member has been adjusted accordingly for Darwin-based systems. Signed-off-by: Trent Huber <trentmhuber@gmail.com> Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Diffstat (limited to 'os-posix.c')
-rw-r--r--os-posix.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/os-posix.c b/os-posix.c
index a4284e2c07..43f9a43f3f 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -270,7 +270,11 @@ void os_setup_limits(void)
return;
}
+#ifdef CONFIG_DARWIN
+ nofile.rlim_cur = OPEN_MAX < nofile.rlim_max ? OPEN_MAX : nofile.rlim_max;
+#else
nofile.rlim_cur = nofile.rlim_max;
+#endif
if (setrlimit(RLIMIT_NOFILE, &nofile) < 0) {
warn_report("unable to set NOFILE limit: %s", strerror(errno));