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 /process.c | |
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
Diffstat (limited to 'process.c')
-rw-r--r-- | process.c | 48 |
1 files changed, 48 insertions, 0 deletions
@@ -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) |