From bd153422f28634bb6e53f13f80beb8289d405267 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Wed, 30 Sep 2020 13:32:59 -0400 Subject: 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. --- src/process/fork.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/process/fork.c (limited to 'src/process/fork.c') 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 +#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; +} -- cgit v1.2.3-60-g2f50