qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 2/2] qemu/osdep: handle sysconf(_SC_OPEN_MAX) return value ==


From: Michael Tokarev
Subject: Re: [PATCH 2/2] qemu/osdep: handle sysconf(_SC_OPEN_MAX) return value == -1
Date: Fri, 30 Aug 2024 14:31:06 +0300
User-agent: Mozilla Thunderbird

30.08.2024 14:14, Clément Léger wrote:
On some systems (MacOS for instance), sysconf(_SC_OPEN_MAX) can return
-1. In that case we should fallback to using the OPEN_MAX define.
According to "man sysconf", the OPEN_MAX define should be present and
provided by either unistd.h and/or limits.h so include them for that
purpose. For other OSes, just assume a maximum of 1024 files descriptors
as a fallback.

Fixes: 4ec5ebea078e ("qemu/osdep: Move close_all_open_fds() to oslib-posix")
Reported-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Clément Léger <cleger@rivosinc.com>

Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>

@@ -928,6 +933,13 @@ static void qemu_close_all_open_fd_fallback(const int 
*skip, unsigned int nskip,
  void qemu_close_all_open_fd(const int *skip, unsigned int nskip)
  {
      int open_max = sysconf(_SC_OPEN_MAX);
+    if (open_max == -1) {
+#ifdef CONFIG_DARWIN
+        open_max = OPEN_MAX;
+#else
+        open_max = 1024;
+#endif

BTW, Can we PLEASE cap this to 1024 in all cases? :)
(unrelated to this change but still).

/mjt



reply via email to

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