|
From: | Richard Henderson |
Subject: | Re: [PATCH v6 2/5] qemu/osdep: Split qemu_close_all_open_fd() and add fallback |
Date: | Wed, 31 Jul 2024 11:56:21 +1000 |
User-agent: | Mozilla Thunderbird |
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~
[Prev in Thread] | Current Thread | [Next in Thread] |