diff options
author | Bobby Bingham <koorogi@koorogi.info> | 2017-11-10 18:15:43 -0600 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2017-11-10 19:27:57 -0500 |
commit | c21051e90cd27a0b26be0ac66950b7396a156ba1 (patch) | |
tree | aa4367f565765f4e8b155e19b320fac6b68eaa40 /src | |
parent | a39f20bf9f8e59573a479bff23df345b2b4d2345 (diff) | |
download | musl-c21051e90cd27a0b26be0ac66950b7396a156ba1.tar.gz musl-c21051e90cd27a0b26be0ac66950b7396a156ba1.tar.bz2 musl-c21051e90cd27a0b26be0ac66950b7396a156ba1.tar.xz musl-c21051e90cd27a0b26be0ac66950b7396a156ba1.zip |
prevent fork's errno from being clobbered by atfork handlers
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/process/fork.c | 6 |
1 files 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); } |