ruby-changes:23893
From: akr <ko1@a...>
Date: Wed, 6 Jun 2012 20:49:44 +0900 (JST)
Subject: [ruby-changes:23893] akr:r35944 (trunk): * process.c (proc_exec_v): don't call dln_find_exe_r here because it
akr 2012-06-06 20:49:30 +0900 (Wed, 06 Jun 2012) New Revision: 35944 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35944 Log: * process.c (proc_exec_v): don't call dln_find_exe_r here because it is not async-signal-safe and proc_exec_v is called in a child process. command_abspath field of rb_exec_arg. (rb_exec_fillarg): call dln_find_exe_r and set command_abspath. (rb_exec_err): Give the absolute path of the invoking command for proc_exec_v, instead of the command name. * internal.h: add command_abspath field for rb_exec_arg. Modified files: trunk/ChangeLog trunk/internal.h trunk/process.c Index: ChangeLog =================================================================== --- ChangeLog (revision 35943) +++ ChangeLog (revision 35944) @@ -1,3 +1,15 @@ +Wed Jun 6 20:45:08 2012 Tanaka Akira <akr@f...> + + * process.c (proc_exec_v): don't call dln_find_exe_r here because it + is not async-signal-safe and proc_exec_v is called in a child + process. + command_abspath field of rb_exec_arg. + (rb_exec_fillarg): call dln_find_exe_r and set command_abspath. + (rb_exec_err): Give the absolute path of the invoking command for + proc_exec_v, instead of the command name. + + * internal.h: add command_abspath field for rb_exec_arg. + Wed Jun 6 20:08:01 2012 Tanaka Akira <akr@f...> * process.c (try_with_sh): take envp argument. Index: process.c =================================================================== --- process.c (revision 35943) +++ process.c (revision 35944) @@ -1077,7 +1077,6 @@ UNREACHABLE; #else char **argv; - char fbuf[MAXPATHLEN]; char **envp; # if defined(__EMX__) || defined(OS2) char **new_argv = NULL; @@ -1085,9 +1084,6 @@ argv = ARGVSTR2ARGV(argv_str); - if (!prog) - prog = argv[0]; - prog = dln_find_exe_r(prog, 0, fbuf, sizeof(fbuf)); /* xxx: not async-signal-safe because getenv(), strdup(), etc. */ if (!prog) { errno = ENOENT; return -1; @@ -1767,6 +1763,8 @@ rb_exec_fillarg(VALUE prog, int argc, VALUE *argv, VALUE env, VALUE opthash, struct rb_exec_arg *e) { VALUE options; + char fbuf[MAXPATHLEN]; + MEMZERO(e, struct rb_exec_arg, 1); options = hide_obj(rb_ary_new()); e->options = options; @@ -1823,6 +1821,15 @@ } #endif + if (!e->use_shell) { + char *abspath; + abspath = dln_find_exe_r(RSTRING_PTR(e->invoke.cmd.command_name), 0, fbuf, sizeof(fbuf)); + if (abspath) + e->invoke.cmd.command_abspath = rb_str_new_cstr(abspath); + else + e->invoke.cmd.command_abspath = Qnil; + } + if (!e->use_shell && !e->invoke.cmd.argv_buf) { int i; VALUE argv_buf; @@ -2604,7 +2611,10 @@ rb_proc_exec_e(RSTRING_PTR(e->invoke.sh.shell_script), e->envp_str); /* not async-signal-safe because after_exec. */ } else { - proc_exec_v(RSTRING_PTR(e->invoke.cmd.command_name), e->invoke.cmd.argv_str, e->envp_str); /* not async-signal-safe because dln_find_exe_r */ + char *abspath = NULL; + if (!NIL_P(e->invoke.cmd.command_abspath)) + abspath = RSTRING_PTR(e->invoke.cmd.command_abspath); + proc_exec_v(abspath, e->invoke.cmd.argv_str, e->envp_str); /* async-signal-safe */ } #if !defined(HAVE_FORK) preserving_errno(rb_run_exec_options_err(sargp, NULL, errmsg, errmsg_buflen)); @@ -2642,7 +2652,7 @@ rb_exec_atfork(void* arg, char *errmsg, size_t errmsg_buflen) { rb_thread_atfork_before_exec(); /* xxx: not async-signal-safe because it calls rb_thread_atfork_internal which calls st_insert, etc. */ - return rb_exec_err(arg, errmsg, errmsg_buflen); /* not async-signal-safe because after_exec and dln_find_exe_r */ + return rb_exec_err(arg, errmsg, errmsg_buflen); /* not async-signal-safe because after_exec */ } #endif Index: internal.h =================================================================== --- internal.h (revision 35943) +++ internal.h (revision 35944) @@ -167,6 +167,7 @@ } sh; struct { VALUE command_name; + VALUE command_abspath; /* full path string or nil */ VALUE argv_str; VALUE argv_buf; } cmd; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/