ruby-changes:23951
From: akr <ko1@a...>
Date: Sun, 10 Jun 2012 10:30:08 +0900 (JST)
Subject: [ruby-changes:23951] akr:r36002 (trunk): * process.c (rb_exec_async_signal_safe): exported.
akr 2012-06-10 10:29:58 +0900 (Sun, 10 Jun 2012) New Revision: 36002 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36002 Log: * process.c (rb_exec_async_signal_safe): exported. * ext/pty/extconf.rb: modify $INCFLAGS to include internal.h * ext/pty/pty.c: include internal.h. (chfunc): don't call rb_thread_atfork_before_exec. use rb_exec_async_signal_safe instead of rb_f_exec. (establishShell): set up earg. use rb_fork_async_signal_safe instead of rb_fork_err. * internal.h (rb_exec_async_signal_safe): declared. (rb_fork_async_signal_safe): declared. Modified files: trunk/ChangeLog trunk/ext/pty/extconf.rb trunk/ext/pty/pty.c trunk/internal.h trunk/process.c Index: ChangeLog =================================================================== --- ChangeLog (revision 36001) +++ ChangeLog (revision 36002) @@ -1,3 +1,18 @@ +Sun Jun 10 10:24:51 2012 Tanaka Akira <akr@f...> + + * process.c (rb_exec_async_signal_safe): exported. + + * ext/pty/extconf.rb: modify $INCFLAGS to include internal.h + + * ext/pty/pty.c: include internal.h. + (chfunc): don't call rb_thread_atfork_before_exec. use + rb_exec_async_signal_safe instead of rb_f_exec. + (establishShell): set up earg. use rb_fork_async_signal_safe + instead of rb_fork_err. + + * internal.h (rb_exec_async_signal_safe): declared. + (rb_fork_async_signal_safe): declared. + Sun Jun 10 10:21:37 2012 Martin Bosslet <Martin.Bosslet@g...> * ext/openssl/ossl.c Index: process.c =================================================================== --- process.c (revision 36001) +++ process.c (revision 36002) @@ -2610,7 +2610,7 @@ } /* This function should be async-signal-safe. Hopefully it is. */ -static int +int rb_exec_async_signal_safe(const struct rb_exec_arg *e, char *errmsg, size_t errmsg_buflen) { #if !defined(HAVE_FORK) Index: ext/pty/extconf.rb =================================================================== --- ext/pty/extconf.rb (revision 36001) +++ ext/pty/extconf.rb (revision 36002) @@ -1,5 +1,7 @@ require 'mkmf' +$INCFLAGS << " -I$(topdir) -I$(top_srcdir)" + if /mswin|mingw|bccwin|nacl/ !~ RUBY_PLATFORM have_header("sys/stropts.h") have_func("setresuid") Index: ext/pty/pty.c =================================================================== --- ext/pty/pty.c (revision 36001) +++ ext/pty/pty.c (revision 36002) @@ -32,6 +32,7 @@ #include "ruby/ruby.h" #include "ruby/io.h" #include "ruby/util.h" +#include "internal.h" #include <signal.h> #ifdef HAVE_SYS_STROPTS_H @@ -77,8 +78,7 @@ struct child_info { int master, slave; char *slavename; - int argc; - VALUE *argv; + struct rb_exec_arg earg; }; static int @@ -87,16 +87,12 @@ struct child_info *carg = data; int master = carg->master; int slave = carg->slave; - int argc = carg->argc; - VALUE *argv = carg->argv; #define ERROR_EXIT(str) do { \ strlcpy(errbuf, (str), errbuf_len); \ return -1; \ } while (0) - rb_thread_atfork_before_exec(); - /* * Set free from process group and controlling terminal */ @@ -146,8 +142,7 @@ seteuid(getuid()); #endif - rb_f_exec(argc, argv); - return 0; + return rb_exec_async_signal_safe(&carg->earg, errbuf, sizeof(errbuf_len)); #undef ERROR_EXIT } @@ -181,15 +176,16 @@ argv = &v; } + rb_exec_arg_init(argc, argv, 1, &carg.earg); + rb_exec_arg_fixup(&carg.earg); + getDevice(&master, &slave, SlaveName, 0); carg.master = master; carg.slave = slave; carg.slavename = SlaveName; - carg.argc = argc; - carg.argv = argv; errbuf[0] = '\0'; - pid = rb_fork_err(&status, chfunc, &carg, Qnil, errbuf, sizeof(errbuf)); + pid = rb_fork_async_signal_safe(&status, chfunc, &carg, Qnil, errbuf, sizeof(errbuf)); if (pid < 0) { int e = errno; Index: internal.h =================================================================== --- internal.h (revision 36001) +++ internal.h (revision 36002) @@ -261,6 +261,10 @@ /* io.c */ void rb_maygvl_fd_fix_cloexec(int fd); +/* process.c */ +int rb_exec_async_signal_safe(const struct rb_exec_arg *e, char *errmsg, size_t errmsg_buflen); +rb_pid_t rb_fork_async_signal_safe(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALUE fds, char *errmsg, size_t errmsg_buflen); + #if defined __GNUC__ && __GNUC__ >= 4 #pragma GCC visibility pop #endif -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/