projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix public clone function to be safe and usable by applications
[musl]
/
src
/
process
/
_Fork.c
diff --git
a/src/process/_Fork.c
b/src/process/_Fork.c
index
e765086
..
9c07792
100644
(file)
--- a/
src/process/_Fork.c
+++ b/
src/process/_Fork.c
@@
-5,21
+5,13
@@
#include "lock.h"
#include "pthread_impl.h"
#include "aio_impl.h"
#include "lock.h"
#include "pthread_impl.h"
#include "aio_impl.h"
+#include "fork_impl.h"
static void dummy(int x) { }
weak_alias(dummy, __aio_atfork);
static void dummy(int x) { }
weak_alias(dummy, __aio_atfork);
-
pid_t _Fork(void
)
+
void __post_Fork(int ret
)
{
{
- pid_t ret;
- sigset_t set;
- __block_all_sigs(&set);
- LOCK(__abort_lock);
-#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_set_tid_address, &__thread_list_lock);
if (!ret) {
pthread_t self = __pthread_self();
self->tid = __syscall(SYS_set_tid_address, &__thread_list_lock);
@@
-32,6
+24,20
@@
pid_t _Fork(void)
}
UNLOCK(__abort_lock);
if (!ret) __aio_atfork(1);
}
UNLOCK(__abort_lock);
if (!ret) __aio_atfork(1);
+}
+
+pid_t _Fork(void)
+{
+ pid_t ret;
+ sigset_t set;
+ __block_all_sigs(&set);
+ LOCK(__abort_lock);
+#ifdef SYS_fork
+ ret = __syscall(SYS_fork);
+#else
+ ret = __syscall(SYS_clone, SIGCHLD, 0);
+#endif
+ __post_Fork(ret);
__restore_sigs(&set);
return __syscall_ret(ret);
}
__restore_sigs(&set);
return __syscall_ret(ret);
}