From: Richard Henderson <richard.henderson@linaro.org>
To: Bin Meng <bmeng@tinylab.org>, qemu-devel@nongnu.org
Cc: Zhangjin Wu <falcon@tinylab.org>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
Markus Armbruster <armbru@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH v2 3/6] util/async-teardown: Fall back to close fds one by one
Date: Mon, 19 Jun 2023 08:59:43 +0200 [thread overview]
Message-ID: <c1e1c570-828a-f943-adfe-7d0fc05a2389@linaro.org> (raw)
In-Reply-To: <20230616152737.23545-4-bmeng@tinylab.org>
On 6/16/23 17:27, Bin Meng wrote:
> When opening /proc/self/fd fails, current codes just return directly,
> but we can fall back to close fds one by one.
>
> Signed-off-by: Bin Meng <bmeng@tinylab.org>
> ---
>
> (no changes since v1)
>
> util/async-teardown.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/util/async-teardown.c b/util/async-teardown.c
> index 3ab19c8740..7e0177a8da 100644
> --- a/util/async-teardown.c
> +++ b/util/async-teardown.c
> @@ -48,7 +48,11 @@ static void close_all_open_fd(void)
>
> dir = opendir("/proc/self/fd");
> if (!dir) {
> - /* If /proc is not mounted, there is nothing that can be done. */
> + /* If /proc is not mounted, close fds one by one. */
> + int open_max = sysconf(_SC_OPEN_MAX), i;
> + for (i = 0; i < open_max; i++) {
> + close(i);
> + }
> return;
> }
> /* Avoid closing the directory. */
Do we really need to make the 1M close calls?
The process is on its way to exit anyway...
r~
next prev parent reply other threads:[~2023-06-19 7:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-16 15:27 [PATCH v2 0/6] net/tap: Fix QEMU frozen issue when the maximum number of file descriptors is very large Bin Meng
2023-06-16 15:27 ` [PATCH v2 1/6] tests/tcg/cris: Fix the coding style Bin Meng
2023-06-19 6:55 ` Richard Henderson
2023-06-16 15:27 ` [PATCH v2 2/6] tests/tcg/cris: Correct the off-by-one error Bin Meng
2023-06-19 6:55 ` Richard Henderson
2023-06-16 15:27 ` [PATCH v2 3/6] util/async-teardown: Fall back to close fds one by one Bin Meng
2023-06-19 6:59 ` Richard Henderson [this message]
2023-06-16 15:27 ` [PATCH v2 4/6] utils/osdep: Introduce qemu_close_range() Bin Meng
2023-06-19 7:03 ` Richard Henderson
2023-06-19 7:07 ` Richard Henderson
2023-06-16 15:27 ` [PATCH v2 5/6] util/async-teardown: Use qemu_close_range() to close fds Bin Meng
2023-06-19 7:05 ` Richard Henderson
2023-06-16 15:27 ` [PATCH v2 6/6] net: tap: " Bin Meng
2023-06-19 7:08 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c1e1c570-828a-f943-adfe-7d0fc05a2389@linaro.org \
--to=richard.henderson@linaro.org \
--cc=armbru@redhat.com \
--cc=bmeng@tinylab.org \
--cc=falcon@tinylab.org \
--cc=imbrenda@linux.ibm.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).