diff options
author | Rich Felker <dalias@aerifal.cx> | 2020-09-30 13:32:59 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2020-10-14 20:27:12 -0400 |
commit | bd153422f28634bb6e53f13f80beb8289d405267 (patch) | |
tree | 8d977a1d82b3cc2cceece17357bac02add23b8d4 /src | |
parent | e1e98d869c5b3ebf59e0d0006c108daf0368245e (diff) | |
download | musl-bd153422f28634bb6e53f13f80beb8289d405267.tar.gz musl-bd153422f28634bb6e53f13f80beb8289d405267.tar.bz2 musl-bd153422f28634bb6e53f13f80beb8289d405267.tar.xz musl-bd153422f28634bb6e53f13f80beb8289d405267.zip |
implement _Fork and refactor fork using it
the _Fork interface is defined for future issue of POSIX as the
outcome of Austin Group issue 62, which drops the AS-safety
requirement for fork, and provides an AS-safe replacement that does
not run the registered atfork handlers.
Diffstat (limited to 'src')
-rw-r--r-- | src/process/_Fork.c | 11 | ||||
-rw-r--r-- | src/process/fork.c | 13 |
2 files changed, 15 insertions, 9 deletions
diff --git a/src/process/_Fork.c b/src/process/_Fork.c index 17fb87ad..1f41197c 100644 --- a/src/process/_Fork.c +++ b/src/process/_Fork.c @@ -1,23 +1,17 @@ #include <unistd.h> -#include <string.h> #include <signal.h> #include "syscall.h" #include "libc.h" #include "lock.h" #include "pthread_impl.h" -static void dummy(int x) -{ -} - -weak_alias(dummy, __fork_handler); +static void dummy(int x) { } weak_alias(dummy, __aio_atfork); -pid_t fork(void) +pid_t _Fork(void) { pid_t ret; sigset_t set; - __fork_handler(-1); __block_all_sigs(&set); __aio_atfork(-1); LOCK(__abort_lock); @@ -39,6 +33,5 @@ pid_t fork(void) UNLOCK(__abort_lock); __aio_atfork(!ret); __restore_sigs(&set); - __fork_handler(!ret); return __syscall_ret(ret); } diff --git a/src/process/fork.c b/src/process/fork.c new file mode 100644 index 00000000..a12da01a --- /dev/null +++ b/src/process/fork.c @@ -0,0 +1,13 @@ +#include <unistd.h> +#include "libc.h" + +static void dummy(int x) { } +weak_alias(dummy, __fork_handler); + +pid_t fork(void) +{ + __fork_handler(-1); + pid_t ret = _Fork(); + __fork_handler(!ret); + return ret; +} |