mirror of
https://github.com/fluencelabs/musl
synced 2025-06-14 07:21:40 +00:00
add pthread_atfork interface
note that this presently does not handle consistency of the libc's own global state during forking. as per POSIX 2008, if the parent process was threaded, the child process may only call async-signal-safe functions until one of the exec-family functions is called, so the current behavior is believed to be conformant even if non-ideal. it may be improved at some later time.
This commit is contained in:
@ -1,9 +1,12 @@
|
||||
#include <unistd.h>
|
||||
#include "syscall.h"
|
||||
|
||||
/* FIXME: add support for atfork stupidity */
|
||||
#include "libc.h"
|
||||
|
||||
pid_t fork(void)
|
||||
{
|
||||
return syscall0(__NR_fork);
|
||||
pid_t ret;
|
||||
if (libc.fork_handler) libc.fork_handler(-1);
|
||||
ret = syscall0(__NR_fork);
|
||||
if (libc.fork_handler) libc.fork_handler(!ret);
|
||||
return ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user