diff options
author | kib <kib@FreeBSD.org> | 2014-06-07 02:45:24 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2014-06-07 02:45:24 +0000 |
commit | 8d9dc2de3a37d5f757fffb376a780d5081675f2e (patch) | |
tree | 747c00fc9e7b43e6077655fb1d4c318340f89b0e /lib/libthr/thread/thr_fork.c | |
parent | 218f93e5f8ff4d66b5b39b99db1d741e7067e773 (diff) | |
download | FreeBSD-src-8d9dc2de3a37d5f757fffb376a780d5081675f2e.zip FreeBSD-src-8d9dc2de3a37d5f757fffb376a780d5081675f2e.tar.gz |
MFC r266609:
Change the _rtld_atfork() to lock the bind lock in write mode.
Diffstat (limited to 'lib/libthr/thread/thr_fork.c')
-rw-r--r-- | lib/libthr/thread/thr_fork.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/libthr/thread/thr_fork.c b/lib/libthr/thread/thr_fork.c index c26541e..fc87688 100644 --- a/lib/libthr/thread/thr_fork.c +++ b/lib/libthr/thread/thr_fork.c @@ -57,6 +57,7 @@ * */ +#include <sys/syscall.h> #include "namespace.h" #include <errno.h> #include <link.h> @@ -174,8 +175,15 @@ _fork(void) was_threaded = 0; } - /* Fork a new process: */ - if ((ret = __sys_fork()) == 0) { + /* + * Fork a new process. + * There is no easy way to pre-resolve the __sys_fork symbol + * without performing the fork. Use the syscall(2) + * indirection, the syscall symbol is resolved in + * _thr_rtld_init() with side-effect free call. + */ + ret = syscall(SYS_fork); + if (ret == 0) { /* Child process */ errsave = errno; curthread->cancel_pending = 0; @@ -250,6 +258,5 @@ _fork(void) } errno = errsave; - /* Return the process ID: */ return (ret); } |