qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] os-posix: Expand setrlimit() syscall compatibility


From: Trent Huber
Subject: [PATCH] os-posix: Expand setrlimit() syscall compatibility
Date: Fri, 14 Jun 2024 01:14:22 -0400

Darwin (I'm running version 19.6.0) uses a subtly different version
of the setrlimit() syscall as described in the COMPATIBILITY section
of the macOS man page. I adjusted the way the rlim_cur member is set
to accommodate and which shouldn't affect any non-Darwin systems.

Signed-off-by: Trent Huber <trentmhuber@gmail.com>
---
 os-posix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/os-posix.c b/os-posix.c
index a4284e2c07..5766346521 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -270,7 +270,7 @@ void os_setup_limits(void)
         return;
     }
 
-    nofile.rlim_cur = nofile.rlim_max;
+    nofile.rlim_cur = OPEN_MAX < nofile.rlim_max ? OPEN_MAX : nofile.rlim_max;
 
     if (setrlimit(RLIMIT_NOFILE, &nofile) < 0) {
         warn_report("unable to set NOFILE limit: %s", strerror(errno));
-- 
2.24.3 (Apple Git-128)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]