From: Florian Weimer <fweimer@redhat.com>
To: Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
Subject: Re: [PATCH v4 2/4] posix: Do not clobber errno by atfork handlers
Date: Thu, 24 Jun 2021 10:19:00 +0200 [thread overview]
Message-ID: <877dijn097.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <20210623184354.395316-3-adhemerval.zanella@linaro.org> (Adhemerval Zanella via Libc-alpha's message of "Wed, 23 Jun 2021 15:43:52 -0300")
* Adhemerval Zanella via Libc-alpha:
> Checked on x86_64-linux-gnu.
> ---
> posix/fork.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/posix/fork.c b/posix/fork.c
> index 44caf8d166..9340511198 100644
> --- a/posix/fork.c
> +++ b/posix/fork.c
> @@ -103,6 +103,9 @@ __libc_fork (void)
> }
> else
> {
> + /* If _Fork failed, preserve its errno value. */
> + int save_errno = errno;
> +
> /* Release acquired locks in the multi-threaded case. */
> if (multiple_threads)
> {
> @@ -115,6 +118,8 @@ __libc_fork (void)
>
> /* Run the handlers registered for the parent. */
> __run_fork_handlers (atfork_run_parent, multiple_threads);
> +
> + __set_errno (save_errno);
I think you should restrict the __set_errno call to pid < 0, so that
errno is not 0 after a different value has been observed by the fork
handlers.
Thanks,
Florian
next prev parent reply other threads:[~2021-06-24 8:19 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-23 18:43 [PATCH v4 0/4] Add _Fork implementation Adhemerval Zanella
2021-06-23 18:43 ` [PATCH v4 1/4] posix: Consolidate fork implementation Adhemerval Zanella
2021-06-24 8:15 ` Florian Weimer
2021-06-24 11:32 ` Adhemerval Zanella
2021-06-23 18:43 ` [PATCH v4 2/4] posix: Do not clobber errno by atfork handlers Adhemerval Zanella
2021-06-24 8:19 ` Florian Weimer [this message]
2021-06-24 11:05 ` Adhemerval Zanella
2021-06-24 11:19 ` Florian Weimer
2021-06-24 11:32 ` Adhemerval Zanella
2021-06-23 18:43 ` [PATCH v4 3/4] Consolidate pthread_atfork Adhemerval Zanella
2021-06-24 8:22 ` Florian Weimer
2021-06-24 11:32 ` Adhemerval Zanella
2021-06-23 18:43 ` [PATCH v4 4/4] posix: Add _Fork [BZ #4737] Adhemerval Zanella
2021-06-24 8:47 ` Florian Weimer
2021-06-24 13:34 ` Adhemerval Zanella
2021-06-28 8:52 ` Florian Weimer
2021-06-28 18:10 ` Adhemerval Zanella
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=877dijn097.fsf@oldenburg.str.redhat.com \
--to=fweimer@redhat.com \
--cc=libc-alpha@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).