diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-06-10 21:31:49 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-06-10 21:31:49 +0000 |
commit | 9ea35ccf306cda49f3ec1ab02ae1570f68e02765 (patch) | |
tree | dc1f6a8d7e08299b77d6f60c474c370576e97ecc | |
parent | 35973f273c3f6146a4b1a0c1597b0c1fc1d7b445 (diff) | |
download | ruby-9ea35ccf306cda49f3ec1ab02ae1570f68e02765.tar.gz |
* process.c (rb_proc_exec_n): revert the function removed at r35889.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | include/ruby/intern.h | 1 | ||||
-rw-r--r-- | process.c | 48 |
3 files changed, 53 insertions, 0 deletions
@@ -1,3 +1,7 @@ +Mon Jun 11 06:31:33 2012 Tanaka Akira <akr@fsij.org> + + * process.c (rb_proc_exec_n): revert the function removed at r35889. + Mon Jun 11 06:20:50 2012 NARUSE, Yui <naruse@ruby-lang.org> * thread_pthread.c (rb_thread_create_timer_thread): assign return diff --git a/include/ruby/intern.h b/include/ruby/intern.h index 05663d9bae..1c353dcd7c 100644 --- a/include/ruby/intern.h +++ b/include/ruby/intern.h @@ -607,6 +607,7 @@ struct rb_exec_arg { VALUE envp_buf; VALUE dup2_tmpbuf; }; +int rb_proc_exec_n(int, VALUE*, const char*); int rb_proc_exec(const char*); VALUE rb_exec_arg_init(int argc, VALUE *argv, int accept_shell, struct rb_exec_arg *e); int rb_exec_arg_addopt(struct rb_exec_arg *e, VALUE key, VALUE val); @@ -1147,6 +1147,54 @@ proc_exec_cmd(const char *prog, VALUE argv_str, VALUE envp_str) #endif } +/* deprecated */ +static int +proc_exec_v(char **argv, const char *prog) +{ + char fbuf[MAXPATHLEN]; + + if (!prog) + prog = argv[0]; + prog = dln_find_exe_r(prog, 0, fbuf, sizeof(fbuf)); + if (!prog) { + errno = ENOENT; + return -1; + } + before_exec(); + execv(prog, argv); + preserving_errno(try_with_sh(prog, argv, 0); after_exec()); + return -1; +} + +/* deprecated */ +int +rb_proc_exec_n(int argc, VALUE *argv, const char *prog) +{ +#define ARGV_COUNT(n) ((n)+1) +#define ARGV_SIZE(n) (sizeof(char*) * ARGV_COUNT(n)) +#define ALLOC_ARGV(n, v) ALLOCV_N(char*, (v), ARGV_COUNT(n)) + + char **args; + int i; + int ret = -1; + VALUE v; + + args = ALLOC_ARGV(argc+1, v); + for (i=0; i<argc; i++) { + args[i] = RSTRING_PTR(argv[i]); + } + args[i] = 0; + if (args[0]) { + ret = proc_exec_v(args, prog); + } + ALLOCV_END(v); + return ret; + +#undef ARGV_COUNT +#undef ARGV_SIZE +#undef ALLOC_ARGV +} + /* This function should be async-signal-safe. Actually it is. */ static int proc_exec_sh(const char *str, VALUE envp_str) |