X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fprocess%2Ffork.c;h=f8cf21e7ca01d94cd67a2add5bcda4ccaff7af40;hb=e89cfe51d2001af08fc2a13e5133ba8157f90beb;hp=1a82f4286bacdf24eef48e9a7107ba8fc9b79e60;hpb=d4d6d6f322cd13cfca2b179345cdcf67997c3529;p=musl diff --git a/src/process/fork.c b/src/process/fork.c index 1a82f428..f8cf21e7 100644 --- a/src/process/fork.c +++ b/src/process/fork.c @@ -1,5 +1,6 @@ #include #include +#include #include "syscall.h" #include "libc.h" #include "pthread_impl.h" @@ -16,13 +17,16 @@ pid_t fork(void) sigset_t set; __fork_handler(-1); __block_all_sigs(&set); +#ifdef SYS_fork ret = syscall(SYS_fork); - if (libc.main_thread && !ret) { +#else + ret = syscall(SYS_clone, SIGCHLD, 0); +#endif + if (libc.has_thread_pointer && !ret) { pthread_t self = __pthread_self(); - self->tid = self->pid = syscall(SYS_getpid); + self->tid = self->pid = __syscall(SYS_getpid); memset(&self->robust_list, 0, sizeof self->robust_list); libc.threads_minus_1 = 0; - libc.main_thread = self; } __restore_sigs(&set); __fork_handler(!ret);