From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Trent Huber <trentmhuber@gmail.com>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, pbonzini@redhat.com
Subject: Re: [PATCH v2] os-posix: Expand setrlimit() syscall compatibility
Date: Mon, 17 Jun 2024 09:19:17 +0200 [thread overview]
Message-ID: <b9ed9c39-349d-4397-9b05-d7faa5b95fa2@linaro.org> (raw)
In-Reply-To: <20240614210638.5959-1-trentmhuber@gmail.com>
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));
next prev parent reply other threads:[~2024-06-17 7:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-14 21:06 [PATCH v2] os-posix: Expand setrlimit() syscall compatibility Trent Huber
2024-06-17 7:19 ` Philippe Mathieu-Daudé [this message]
2024-06-17 13:07 ` Michael Tokarev
2024-06-17 15:15 ` Philippe Mathieu-Daudé
2024-06-17 18:21 ` Richard Henderson
2024-06-17 12:52 ` Daniel P. Berrangé
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=b9ed9c39-349d-4397-9b05-d7faa5b95fa2@linaro.org \
--to=philmd@linaro.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=trentmhuber@gmail.com \
/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).