| OLD | NEW |
| 1 #include <unistd.h> | 1 #include <unistd.h> |
| 2 #include <string.h> | 2 #include <string.h> |
| 3 #include <signal.h> | 3 #include <signal.h> |
| 4 #include "syscall.h" | 4 #include "syscall.h" |
| 5 #include "libc.h" | 5 #include "libc.h" |
| 6 #include "pthread_impl.h" | 6 #include "pthread_impl.h" |
| 7 | 7 |
| 8 static void dummy(int x) | 8 static void dummy(int x) {} |
| 9 { | |
| 10 } | |
| 11 | 9 |
| 12 weak_alias(dummy, __fork_handler); | 10 weak_alias(dummy, __fork_handler); |
| 13 | 11 |
| 14 pid_t fork(void) | 12 pid_t fork(void) { |
| 15 { | 13 pid_t ret; |
| 16 » pid_t ret; | 14 sigset_t set; |
| 17 » sigset_t set; | 15 __fork_handler(-1); |
| 18 » __fork_handler(-1); | 16 __block_all_sigs(&set); |
| 19 » __block_all_sigs(&set); | |
| 20 #ifdef SYS_fork | 17 #ifdef SYS_fork |
| 21 » ret = syscall(SYS_fork); | 18 ret = syscall(SYS_fork); |
| 22 #else | 19 #else |
| 23 » ret = syscall(SYS_clone, SIGCHLD, 0); | 20 ret = syscall(SYS_clone, SIGCHLD, 0); |
| 24 #endif | 21 #endif |
| 25 » if (!ret) { | 22 if (!ret) { |
| 26 » » pthread_t self = __pthread_self(); | 23 pthread_t self = __pthread_self(); |
| 27 » » self->tid = __syscall(SYS_gettid); | 24 self->tid = __syscall(SYS_gettid); |
| 28 » » self->robust_list.off = 0; | 25 self->robust_list.off = 0; |
| 29 » » self->robust_list.pending = 0; | 26 self->robust_list.pending = 0; |
| 30 » » libc.threads_minus_1 = 0; | 27 libc.threads_minus_1 = 0; |
| 31 » } | 28 } |
| 32 » __restore_sigs(&set); | 29 __restore_sigs(&set); |
| 33 » __fork_handler(!ret); | 30 __fork_handler(!ret); |
| 34 » return ret; | 31 return ret; |
| 35 } | 32 } |
| OLD | NEW |