qemu-devel
[Top][All Lists]
Advanced

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

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


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v2] os-posix: Expand setrlimit() syscall compatibility
Date: Mon, 17 Jun 2024 09:19:17 +0200
User-agent: Mozilla Thunderbird

Hi Trent,

On 14/6/24 23:06, Trent Huber wrote:
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>
---
The previous version assumed OPEN_MAX was a constant defined on all
POSIX systems--turns out it's only a macOS constant. This version adds
preprocessing conditionals to maintain compatibility with Linux.

  os-posix.c | 4 ++++
  1 file changed, 4 insertions(+)

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;

Why open-code min()? (The man-page also suggests it).

Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>

+#else
      nofile.rlim_cur = nofile.rlim_max;
+#endif
if (setrlimit(RLIMIT_NOFILE, &nofile) < 0) {
          warn_report("unable to set NOFILE limit: %s", strerror(errno));




reply via email to

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