summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--include/ruby/intern.h1
-rw-r--r--process.c48
3 files changed, 53 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 55ed1c047d..c478ead24f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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);
diff --git a/process.c b/process.c
index f48a867ced..0b203e4a71 100644
--- a/process.c
+++ b/process.c
@@ -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)