Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Unified Diff: fusl/src/process/fork.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fusl/src/process/fexecve.c ('k') | fusl/src/process/i386/vfork.s » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fusl/src/process/fork.c
diff --git a/fusl/src/process/fork.c b/fusl/src/process/fork.c
new file mode 100644
index 0000000000000000000000000000000000000000..b96f0024f4c03c86e8ac6d72b4305576d0a020c6
--- /dev/null
+++ b/fusl/src/process/fork.c
@@ -0,0 +1,35 @@
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include "syscall.h"
+#include "libc.h"
+#include "pthread_impl.h"
+
+static void dummy(int x)
+{
+}
+
+weak_alias(dummy, __fork_handler);
+
+pid_t fork(void)
+{
+ pid_t ret;
+ sigset_t set;
+ __fork_handler(-1);
+ __block_all_sigs(&set);
+#ifdef SYS_fork
+ ret = syscall(SYS_fork);
+#else
+ ret = syscall(SYS_clone, SIGCHLD, 0);
+#endif
+ if (!ret) {
+ pthread_t self = __pthread_self();
+ self->tid = __syscall(SYS_gettid);
+ self->robust_list.off = 0;
+ self->robust_list.pending = 0;
+ libc.threads_minus_1 = 0;
+ }
+ __restore_sigs(&set);
+ __fork_handler(!ret);
+ return ret;
+}
« no previous file with comments | « fusl/src/process/fexecve.c ('k') | fusl/src/process/i386/vfork.s » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698