ruby-changes:35279
From: akr <ko1@a...>
Date: Wed, 3 Sep 2014 07:51:15 +0900 (JST)
Subject: [ruby-changes:35279] akr:r47361 (trunk): * configure.in: Use AC_FUNC_FORK.
akr 2014-09-03 07:51:03 +0900 (Wed, 03 Sep 2014) New Revision: 47361 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47361 Log: * configure.in: Use AC_FUNC_FORK. * io.c: Use HAVE_WORKING_FORK instead of HAVE_FORK. * process.c: Ditto. Modified files: trunk/ChangeLog trunk/configure.in trunk/io.c trunk/process.c Index: configure.in =================================================================== --- configure.in (revision 47360) +++ configure.in (revision 47361) @@ -1962,6 +1962,8 @@ else https://github.com/ruby/ruby/blob/trunk/configure.in#L1962 AC_LIBOBJ([signbit]) fi +AC_FUNC_FORK + AC_CHECK_FUNCS(__syscall) AC_CHECK_FUNCS(_longjmp) # used for AC_ARG_WITH(setjmp-type) AC_CHECK_FUNCS(_setjmp) # used for AC_ARG_WITH(setjmp-type) @@ -1984,7 +1986,6 @@ AC_CHECK_FUNCS(fchown) https://github.com/ruby/ruby/blob/trunk/configure.in#L1986 AC_CHECK_FUNCS(fcntl) AC_CHECK_FUNCS(fdatasync) AC_CHECK_FUNCS(fmod) -AC_CHECK_FUNCS(fork) AC_CHECK_FUNCS(fsync) AC_CHECK_FUNCS(ftruncate) AC_CHECK_FUNCS(ftruncate64) # used for Win32 platform @@ -2662,7 +2663,7 @@ if test x"$ac_cv_header_ucontext_h" = xy https://github.com/ruby/ruby/blob/trunk/configure.in#L2663 fi fi -if test "$ac_cv_func_fork" = "yes" -a "$rb_with_pthread" = "yes"; then +if test "$ac_cv_func_fork_works" = "yes" -a "$rb_with_pthread" = "yes"; then AC_CACHE_CHECK([if fork works with pthread], rb_cv_fork_with_pthread, [AC_TRY_RUN([ #include <stdlib.h> Index: ChangeLog =================================================================== --- ChangeLog (revision 47360) +++ ChangeLog (revision 47361) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Sep 3 07:50:15 2014 Tanaka Akira <akr@f...> + + * configure.in: Use AC_FUNC_FORK. + + * io.c: Use HAVE_WORKING_FORK instead of HAVE_FORK. + + * process.c: Ditto. + Wed Sep 3 00:12:44 2014 Tanaka Akira <akr@f...> * process.c (retry_fork_async_signal_safe): Don't return on in child Index: io.c =================================================================== --- io.c (revision 47360) +++ io.c (revision 47361) @@ -5665,7 +5665,7 @@ rb_file_open(const char *fname, const ch https://github.com/ruby/ruby/blob/trunk/io.c#L5665 return rb_file_open_internal(io_alloc(rb_cFile), rb_str_new_cstr(fname), modestr); } -#if defined(__CYGWIN__) || !defined(HAVE_FORK) +#if defined(__CYGWIN__) || !defined(HAVE_WORKING_FORK) static struct pipe_list { rb_io_t *fptr; struct pipe_list *next; @@ -5721,7 +5721,7 @@ pipe_atexit(void) https://github.com/ruby/ruby/blob/trunk/io.c#L5721 static void pipe_finalize(rb_io_t *fptr, int noraise) { -#if !defined(HAVE_FORK) && !defined(_WIN32) +#if !defined(HAVE_WORKING_FORK) && !defined(_WIN32) int status = 0; if (fptr->stdio_file) { status = pclose(fptr->stdio_file); @@ -5773,7 +5773,7 @@ rb_pipe(int *pipes) https://github.com/ruby/ruby/blob/trunk/io.c#L5773 #define spawn(mode, cmd) rb_w32_uspawn((mode), (cmd), 0) #endif -#if defined(HAVE_FORK) || defined(HAVE_SPAWNV) +#if defined(HAVE_WORKING_FORK) || defined(HAVE_SPAWNV) struct popen_arg { VALUE execarg_obj; struct rb_execarg *eargp; @@ -5783,7 +5783,7 @@ struct popen_arg { https://github.com/ruby/ruby/blob/trunk/io.c#L5783 }; #endif -#ifdef HAVE_FORK +#ifdef HAVE_WORKING_FORK static void popen_redirect(struct popen_arg *p) { @@ -5918,11 +5918,11 @@ pipe_open(VALUE execarg_obj, const char https://github.com/ruby/ruby/blob/trunk/io.c#L5918 VALUE port; rb_io_t *write_fptr; VALUE write_port; -#if defined(HAVE_FORK) +#if defined(HAVE_WORKING_FORK) int status; char errmsg[80] = { '\0' }; #endif -#if defined(HAVE_FORK) || defined(HAVE_SPAWNV) +#if defined(HAVE_WORKING_FORK) || defined(HAVE_SPAWNV) int state; struct popen_arg arg; int e = 0; @@ -5937,20 +5937,20 @@ pipe_open(VALUE execarg_obj, const char https://github.com/ruby/ruby/blob/trunk/io.c#L5937 spawnv(P_NOWAIT, (cmd), (args)) : \ spawn(P_NOWAIT, (cmd))) # endif -# if !defined(HAVE_FORK) +# if !defined(HAVE_WORKING_FORK) char **args = NULL; # if defined(HAVE_SPAWNVE) char **envp = NULL; # endif # endif #endif -#if !defined(HAVE_FORK) +#if !defined(HAVE_WORKING_FORK) struct rb_execarg sarg, *sargp = &sarg; #endif FILE *fp = 0; int fd = -1; int write_fd = -1; -#if !defined(HAVE_FORK) +#if !defined(HAVE_WORKING_FORK) const char *cmd = 0; #if !defined(HAVE_SPAWNV) int argc; @@ -5961,13 +5961,13 @@ pipe_open(VALUE execarg_obj, const char https://github.com/ruby/ruby/blob/trunk/io.c#L5961 cmd = StringValueCStr(prog); #endif -#if defined(HAVE_FORK) || defined(HAVE_SPAWNV) +#if defined(HAVE_WORKING_FORK) || defined(HAVE_SPAWNV) arg.execarg_obj = execarg_obj; arg.eargp = eargp; arg.modef = fmode; arg.pair[0] = arg.pair[1] = -1; arg.write_pair[0] = arg.write_pair[1] = -1; -# if !defined(HAVE_FORK) +# if !defined(HAVE_WORKING_FORK) if (eargp && !eargp->use_shell) { args = ARGVSTR2ARGV(eargp->invoke.cmd.argv_str); } @@ -6013,7 +6013,7 @@ pipe_open(VALUE execarg_obj, const char https://github.com/ruby/ruby/blob/trunk/io.c#L6013 rb_jump_tag(state); } -# if defined(HAVE_FORK) +# if defined(HAVE_WORKING_FORK) pid = rb_fork_async_signal_safe(&status, popen_exec, &arg, arg.eargp->redirect_fds, errmsg, sizeof(errmsg)); # else rb_execarg_run_options(eargp, sargp, NULL, 0); @@ -6037,7 +6037,7 @@ pipe_open(VALUE execarg_obj, const char https://github.com/ruby/ruby/blob/trunk/io.c#L6037 # endif } else { -# if defined(HAVE_FORK) +# if defined(HAVE_WORKING_FORK) pid = rb_fork_ruby(&status); if (pid == 0) { /* child */ rb_thread_atfork(); @@ -6053,7 +6053,7 @@ pipe_open(VALUE execarg_obj, const char https://github.com/ruby/ruby/blob/trunk/io.c#L6053 /* parent */ if (pid == -1) { -# if defined(HAVE_FORK) +# if defined(HAVE_WORKING_FORK) e = errno; # endif close(arg.pair[0]); @@ -6063,7 +6063,7 @@ pipe_open(VALUE execarg_obj, const char https://github.com/ruby/ruby/blob/trunk/io.c#L6063 close(arg.write_pair[1]); } errno = e; -# if defined(HAVE_FORK) +# if defined(HAVE_WORKING_FORK) if (errmsg[0]) rb_sys_fail(errmsg); # endif @@ -6134,7 +6134,7 @@ pipe_open(VALUE execarg_obj, const char https://github.com/ruby/ruby/blob/trunk/io.c#L6134 rb_ivar_set(port, rb_intern("@tied_io_for_writing"), write_port); } -#if defined (__CYGWIN__) || !defined(HAVE_FORK) +#if defined (__CYGWIN__) || !defined(HAVE_WORKING_FORK) fptr->finalize = pipe_finalize; pipe_add_fptr(fptr); #endif @@ -6145,7 +6145,7 @@ static int https://github.com/ruby/ruby/blob/trunk/io.c#L6145 is_popen_fork(VALUE prog) { if (RSTRING_LEN(prog) == 1 && RSTRING_PTR(prog)[0] == '-') { -#if !defined(HAVE_FORK) +#if !defined(HAVE_WORKING_FORK) rb_raise(rb_eNotImpError, "fork() function is unimplemented on this machine"); #else @@ -6669,7 +6669,7 @@ io_reopen(VALUE io, VALUE nfile) https://github.com/ruby/ruby/blob/trunk/io.c#L6669 if (RTEST(orig->pathv)) fptr->pathv = orig->pathv; else if (!IS_PREP_STDIO(fptr)) fptr->pathv = Qnil; fptr->finalize = orig->finalize; -#if defined (__CYGWIN__) || !defined(HAVE_FORK) +#if defined (__CYGWIN__) || !defined(HAVE_WORKING_FORK) if (fptr->finalize == pipe_finalize) pipe_add_fptr(fptr); #endif @@ -6837,7 +6837,7 @@ rb_io_init_copy(VALUE dest, VALUE io) https://github.com/ruby/ruby/blob/trunk/io.c#L6837 fptr->lineno = orig->lineno; if (!NIL_P(orig->pathv)) fptr->pathv = orig->pathv; fptr->finalize = orig->finalize; -#if defined (__CYGWIN__) || !defined(HAVE_FORK) +#if defined (__CYGWIN__) || !defined(HAVE_WORKING_FORK) if (fptr->finalize == pipe_finalize) pipe_add_fptr(fptr); #endif Index: process.c =================================================================== --- process.c (revision 47360) +++ process.c (revision 47361) @@ -1181,7 +1181,7 @@ security(const char *str) https://github.com/ruby/ruby/blob/trunk/process.c#L1181 } } -#if defined(HAVE_FORK) && !defined(__native_client__) +#if defined(HAVE_WORKING_FORK) && !defined(__native_client__) /* try_with_sh and exec_with_sh should be async-signal-safe. Actually it is.*/ #define try_with_sh(prog, argv, envp) ((saved_errno == ENOEXEC) ? exec_with_sh((prog), (argv), (envp)) : (void)0) @@ -1382,7 +1382,7 @@ export_dup(VALUE str) https://github.com/ruby/ruby/blob/trunk/process.c#L1382 # define EXPORT_DUP(str) rb_str_dup(str) #endif -#if !defined(HAVE_FORK) && defined(HAVE_SPAWNV) +#if !defined(HAVE_WORKING_FORK) && defined(HAVE_SPAWNV) # define USE_SPAWNV 1 #else # define USE_SPAWNV 0 @@ -2883,7 +2883,7 @@ run_exec_rlimit(VALUE ary, struct rb_exe https://github.com/ruby/ruby/blob/trunk/process.c#L2883 } #endif -#if !defined(HAVE_FORK) +#if !defined(HAVE_WORKING_FORK) static VALUE save_env_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, ary)) { @@ -2937,7 +2937,7 @@ rb_execarg_run_options(const struct rb_e https://github.com/ruby/ruby/blob/trunk/process.c#L2937 } #endif -#if !defined(HAVE_FORK) +#if !defined(HAVE_WORKING_FORK) if (eargp->unsetenv_others_given && eargp->unsetenv_others_do) { save_env(sargp); rb_env_clear(); @@ -2984,7 +2984,7 @@ rb_execarg_run_options(const struct rb_e https://github.com/ruby/ruby/blob/trunk/process.c#L2984 } } -#ifdef HAVE_FORK +#ifdef HAVE_WORKING_FORK if (!eargp->close_others_given || eargp->close_others_do) { rb_close_before_exec(3, eargp->close_others_maxhint, eargp->redirect_fds); /* async-signal-safe */ } @@ -3049,7 +3049,7 @@ rb_execarg_run_options(const struct rb_e https://github.com/ruby/ruby/blob/trunk/process.c#L3049 int rb_exec_async_signal_safe(const struct rb_execarg *eargp, char *errmsg, size_t errmsg_buflen) { -#if !defined(HAVE_FORK) +#if !defined(HAVE_WORKING_FORK) struct rb_execarg sarg, *const sargp = &sarg; #else struct rb_execarg *const sargp = NULL; @@ -3070,7 +3070,7 @@ rb_exec_async_signal_safe(const struct r https://github.com/ruby/ruby/blob/trunk/process.c#L3070 abspath = RSTRING_PTR(eargp->invoke.cmd.command_abspath); proc_exec_cmd(abspath, eargp->invoke.cmd.argv_str, eargp->envp_str); /* async-signal-safe */ } -#if !defined(HAVE_FORK) +#if !defined(HAVE_WORKING_FORK) preserving_errno(rb_execarg_run_options(sargp, NULL, errmsg, errmsg_buflen)); #endif @@ -3091,7 +3091,7 @@ rb_exec_without_timer_thread(const struc https://github.com/ruby/ruby/blob/trunk/process.c#L3091 } #endif -#ifdef HAVE_FORK +#ifdef HAVE_WORKING_FORK /* This function should be async-signal-safe. Hopefully it is. */ static int rb_exec_atfork(void* arg, char *errmsg, size_t errmsg_buflen) @@ -3100,7 +3100,7 @@ rb_exec_atfork(void* arg, char *errmsg, https://github.com/ruby/ruby/blob/trunk/process.c#L3100 } #endif -#ifdef HAVE_FORK +#ifdef HAVE_WORKING_FORK #if SIZEOF_INT == SIZEOF_LONG #define proc_syswait (VALUE (*)(VALUE))rb_syswait #else @@ -3387,7 +3387,7 @@ rb_fork_ruby(int *status) https://github.com/ruby/ruby/blob/trunk/process.c#L3387 #endif -#if defined(HAVE_FORK) && !defined(CANNOT_FORK_WITH_PTHREAD) +#if defined(HAVE_WORKING_FORK) && !defined(CANNOT_FORK_WITH_PTHREAD) /* * call-seq: * Kernel.fork [{ block }] -> fixnum or nil @@ -3617,12 +3617,12 @@ rb_spawn_process(struct rb_execarg *earg https://github.com/ruby/ruby/blob/trunk/process.c#L3617 #if !USE_SPAWNV int status; #endif -#if !defined HAVE_FORK || USE_SPAWNV +#if !defined HAVE_WORKING_FORK || USE_SPAWNV VALUE prog; struct rb_execarg sarg; #endif -#if defined HAVE_FORK && !USE_SPAWNV +#if defined HAVE_WORKING_FORK && !USE_SPAWNV pid = rb_fork_async_signal_safe(&status, rb_exec_atfork, eargp, eargp->redirect_fds, errmsg, errmsg_buflen); #else prog = eargp->use_shell ? eargp->invoke.sh.shell_script : eargp->invoke.cmd.command_name; @@ -3737,7 +3737,7 @@ rb_f_system(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/process.c#L3737 chfunc = signal(SIGCHLD, SIG_DFL); #endif pid = rb_spawn_internal(argc, argv, NULL, 0); -#if defined(HAVE_FORK) || defined(HAVE_SPAWNV) +#if defined(HAVE_WORKING_FORK) || defined(HAVE_SPAWNV) if (pid > 0) { int ret, status; ret = rb_waitpid(pid, &status, 0); @@ -4045,7 +4045,7 @@ rb_f_spawn(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/process.c#L4045 } rb_sys_fail(prog); } -#if defined(HAVE_FORK) || defined(HAVE_SPAWNV) +#if defined(HAVE_WORKING_FORK) || defined(HAVE_SPAWNV) return PIDT2NUM(pid); #else return Qnil; @@ -5681,7 +5681,7 @@ proc_setmaxgroups(VALUE obj, VALUE val) https://github.com/ruby/ruby/blob/trunk/process.c#L5681 #define proc_setmaxgroups rb_f_notimplement #endif -#if defined(HAVE_DAEMON) || (defined(HAVE_FORK) && defined(HAVE_SETSID)) +#if defined(HAVE_DAEMON) || (defined(HAVE_WORKING_FORK) && defined(HAVE_SETSID)) static int rb_daemon(int nochdir, int noclose); /* -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/