public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] posix: Do not clobber errno by atfork handlers
@ 2021-06-24 20:53 Adhemerval Zanella
0 siblings, 0 replies; only message in thread
From: Adhemerval Zanella @ 2021-06-24 20:53 UTC (permalink / raw)
To: glibc-cvs
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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-06-24 20:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-24 20:53 [glibc] posix: Do not clobber errno by atfork handlers Adhemerval Zanella
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).