summaryrefslogtreecommitdiff
path: root/src/process/fork.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2020-09-30 13:32:59 -0400
committerRich Felker <dalias@aerifal.cx>2020-10-14 20:27:12 -0400
commitbd153422f28634bb6e53f13f80beb8289d405267 (patch)
tree8d977a1d82b3cc2cceece17357bac02add23b8d4 /src/process/fork.c
parente1e98d869c5b3ebf59e0d0006c108daf0368245e (diff)
downloadmusl-bd153422f28634bb6e53f13f80beb8289d405267.tar.gz
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/process/fork.c')
-rw-r--r--src/process/fork.c13
1 files changed, 13 insertions, 0 deletions
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;
+}