public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Adhemerval Zanella <azanella@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc] posix: Do not clobber errno by atfork handlers Date: Thu, 24 Jun 2021 20:53:50 +0000 (GMT) [thread overview] Message-ID: <20210624205350.CADDD3888014@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d0c40833862f5cfe4d03d9130d79c1d93f284af0 commit d0c40833862f5cfe4d03d9130d79c1d93f284af0 Author: Adhemerval Zanella <adhemerval.zanella@linaro.org> Date: Thu Jan 21 10:20:54 2021 -0300 posix: Do not clobber errno by atfork handlers Checked on x86_64-linux-gnu. Diff: --- posix/fork.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/posix/fork.c b/posix/fork.c index 44caf8d166..940d6a0955 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,9 @@ __libc_fork (void) /* Run the handlers registered for the parent. */ __run_fork_handlers (atfork_run_parent, multiple_threads); + + if (pid < 0) + __set_errno (save_errno); } return pid;
reply other threads:[~2021-06-24 20:53 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210624205350.CADDD3888014@sourceware.org \ --to=azanella@sourceware.org \ --cc=glibc-cvs@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: linkBe 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).