1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* configure.in: check if fork works with pthread.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2008-06-21 06:54:58 +00:00
parent 7ae9072fdf
commit 3d9c550bf9
2 changed files with 62 additions and 0 deletions

View file

@ -1,3 +1,7 @@
Sat Jun 21 15:54:55 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in: check if fork works with pthread.
Sat Jun 21 15:31:09 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* tool/make-snapshot: ported to ruby.

View file

@ -766,6 +766,64 @@ AC_DEFINE_UNQUOTED([RUBY_SETJMP(env)], [${setjmp_prefix}setjmp(env${setjmp_sigma
AC_DEFINE_UNQUOTED([RUBY_LONGJMP(env,val)], [${setjmp_prefix}longjmp(env,val)])
AC_DEFINE_UNQUOTED(RUBY_JMP_BUF, ${setjmp_sigmask+${setjmp_prefix}}jmp_buf)
case $target_os in
*bsd*|darwin*)
AC_CACHE_CHECK([if fork works with pthread], rb_cv_fork_with_pthread,
[AC_TRY_RUN([
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
void *
thread_func(void *dmy)
{
return dmy;
}
void *use_threads(void)
{
pthread_t tid;
if (pthread_create(&tid, 0, thread_func, 0) != 0) {
exit(1);
}
if (pthread_join(tid, 0) != 0) {
exit(1);
}
}
int
main(int argc, char *argv[])
{
pid_t pid;
use_threads();
pid = fork();
if (pid) {
int loc;
sleep(1);
if (waitpid(pid, &loc, WNOHANG) == 0) {
kill(pid, SIGKILL);
return 1;
}
}
else {
use_threads();
}
return 0;
}]
rb_cv_fork_with_pthread=yes,
rb_cv_fork_with_pthread=no,
rb_cv_fork_with_pthread=yes)])
;;
esac
test x$rb_cv_fork_with_pthread = xyes || AC_DEFINE(CANNOT_FORK_WITH_PTHREAD)
AC_ARG_ENABLE(setreuid,
[ --enable-setreuid use setreuid()/setregid() according to need even if obsolete.],
[use_setreuid=$enableval])