On 7/30/24 22:24, Clément Léger wrote:
+/*
+ * Close all open file descriptors.
+ */
+void qemu_close_all_open_fd(void)
+{
+    int open_max = sysconf(_SC_OPEN_MAX);
+    int i;
+
+    if (qemu_close_all_open_fd_close_range()) {
+        return;
+    }
+
+    if (qemu_close_all_open_fd_proc()) {
+        return;
+    }
+
+    /* Fallback */
+    for (i = 0; i < open_max; i++) {
+        close(i);
+    }
  }

Split out fallback too, because (so far) open_max is only required within the 
fallback.
Then

    if (!qemu_close_all_open_fd_close_range() &&
        !qemu_close_all_open_fd_proc()) {
        qemu_close_all_open_fd_fallback();
    }


r~

Reply via email to