* [PATCH] set errno even if clobbered by atfork handlers
@ 2017-11-11 0:15 Bobby Bingham
2017-11-11 0:29 ` Rich Felker
0 siblings, 1 reply; 2+ messages in thread
From: Bobby Bingham @ 2017-11-11 0:15 UTC (permalink / raw)
To: musl
If the syscall fails, errno must be set correctly for the caller.
There's no guarantee that the handlers registered with pthread_atfork
won't clobber errno, so we need to ensure it gets set after they are
called.
---
src/process/fork.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/process/fork.c b/src/process/fork.c
index b96f0024..da074ae9 100644
--- a/src/process/fork.c
+++ b/src/process/fork.c
@@ -18,9 +18,9 @@ pid_t fork(void)
__fork_handler(-1);
__block_all_sigs(&set);
#ifdef SYS_fork
- ret = syscall(SYS_fork);
+ ret = __syscall(SYS_fork);
#else
- ret = syscall(SYS_clone, SIGCHLD, 0);
+ ret = __syscall(SYS_clone, SIGCHLD, 0);
#endif
if (!ret) {
pthread_t self = __pthread_self();
@@ -31,5 +31,5 @@ pid_t fork(void)
}
__restore_sigs(&set);
__fork_handler(!ret);
- return ret;
+ return __syscall_ret(ret);
}
--
2.15.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] set errno even if clobbered by atfork handlers
2017-11-11 0:15 [PATCH] set errno even if clobbered by atfork handlers Bobby Bingham
@ 2017-11-11 0:29 ` Rich Felker
0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2017-11-11 0:29 UTC (permalink / raw)
To: musl
On Fri, Nov 10, 2017 at 06:15:43PM -0600, Bobby Bingham wrote:
> If the syscall fails, errno must be set correctly for the caller.
> There's no guarantee that the handlers registered with pthread_atfork
> won't clobber errno, so we need to ensure it gets set after they are
> called.
> ---
> src/process/fork.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/process/fork.c b/src/process/fork.c
> index b96f0024..da074ae9 100644
> --- a/src/process/fork.c
> +++ b/src/process/fork.c
> @@ -18,9 +18,9 @@ pid_t fork(void)
> __fork_handler(-1);
> __block_all_sigs(&set);
> #ifdef SYS_fork
> - ret = syscall(SYS_fork);
> + ret = __syscall(SYS_fork);
> #else
> - ret = syscall(SYS_clone, SIGCHLD, 0);
> + ret = __syscall(SYS_clone, SIGCHLD, 0);
> #endif
> if (!ret) {
> pthread_t self = __pthread_self();
> @@ -31,5 +31,5 @@ pid_t fork(void)
> }
> __restore_sigs(&set);
> __fork_handler(!ret);
> - return ret;
> + return __syscall_ret(ret);
> }
> --
> 2.15.0
Thanks, applying (with minor change to top line of commit message so
it's clear this is about fork).
Rich
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-11-11 0:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-11 0:15 [PATCH] set errno even if clobbered by atfork handlers Bobby Bingham
2017-11-11 0:29 ` Rich Felker
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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).