Message ID | 20210503205419.2890929-2-adhemerval.zanella@linaro.org |
---|---|
State | New |
Headers | show |
Series | [v3,1/4] posix: Consolidate fork implementation | expand |
diff --git a/posix/fork.c b/posix/fork.c index cc1bdc1232..ff527a74f2 100644 --- a/posix/fork.c +++ b/posix/fork.c @@ -99,6 +99,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) { @@ -111,6 +114,8 @@ __libc_fork (void) /* Run the handlers registered for the parent. */ __run_fork_handlers (atfork_run_parent, multiple_threads); + + __set_errno (save_errno); } return pid;